Spaces:
Runtime error
Runtime error
lhzstar
commited on
Commit
•
a034be6
1
Parent(s):
a0194f4
new commits
Browse files- app.py +1 -2
- celebbot.py +1 -1
- run_tts.py +11 -2
app.py
CHANGED
@@ -8,7 +8,6 @@ from utils import *
|
|
8 |
def main():
|
9 |
|
10 |
hide_footer()
|
11 |
-
model_list = ["flan-t5-xl"]
|
12 |
celeb_data = get_celeb_data(f'data.json')
|
13 |
|
14 |
st.sidebar.header("CelebChat")
|
@@ -78,7 +77,7 @@ def main():
|
|
78 |
b64 = st.session_state["celeb_bot"].text_to_speech(autoplay=False)
|
79 |
md = f"""
|
80 |
<p>{response}</p>
|
81 |
-
<audio controls autoplay
|
82 |
<source src="data:audio/wav;base64,{b64}" type="audio/wav">
|
83 |
Your browser does not support the audio element.
|
84 |
</audio>
|
|
|
8 |
def main():
|
9 |
|
10 |
hide_footer()
|
|
|
11 |
celeb_data = get_celeb_data(f'data.json')
|
12 |
|
13 |
st.sidebar.header("CelebChat")
|
|
|
77 |
b64 = st.session_state["celeb_bot"].text_to_speech(autoplay=False)
|
78 |
md = f"""
|
79 |
<p>{response}</p>
|
80 |
+
<audio controls autoplay>
|
81 |
<source src="data:audio/wav;base64,{b64}" type="audio/wav">
|
82 |
Your browser does not support the audio element.
|
83 |
</audio>
|
celebbot.py
CHANGED
@@ -108,7 +108,7 @@ class CelebBot():
|
|
108 |
knowledge = self.retrieve_knowledge_assertions()
|
109 |
else:
|
110 |
instruction1 = f'You need to answer the question based on commonsense.'
|
111 |
-
query = f"Context: {instruction1} {knowledge}
|
112 |
input_ids = self.QA_tokenizer(f"{query}", return_tensors="pt").input_ids
|
113 |
outputs = self.QA_model.generate(input_ids, max_length=1024)
|
114 |
self.text = self.QA_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
108 |
knowledge = self.retrieve_knowledge_assertions()
|
109 |
else:
|
110 |
instruction1 = f'You need to answer the question based on commonsense.'
|
111 |
+
query = f"Context: {instruction1} {knowledge}\n\nQuestion: {self.text}\n\nAnswer:"
|
112 |
input_ids = self.QA_tokenizer(f"{query}", return_tensors="pt").input_ids
|
113 |
outputs = self.QA_model.generate(input_ids, max_length=1024)
|
114 |
self.text = self.QA_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
run_tts.py
CHANGED
@@ -17,6 +17,7 @@ import noisereduce as nr
|
|
17 |
import io
|
18 |
from scipy.io.wavfile import write
|
19 |
import base64
|
|
|
20 |
|
21 |
|
22 |
from rtvc.encoder import inference as encoder
|
@@ -116,7 +117,15 @@ def tts(text, embed_name, nlp, autoplay=True):
|
|
116 |
return base64.b64encode(result_bytes).decode()
|
117 |
|
118 |
if __name__ == "__main__":
|
119 |
-
text = "Adkins was raised by a young single mother in various working-class neighbourhoods of London.
|
120 |
embed_name = "Adele"
|
121 |
nlp = spacy.load('en_core_web_sm')
|
122 |
-
tts(text, embed_name, nlp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
import io
|
18 |
from scipy.io.wavfile import write
|
19 |
import base64
|
20 |
+
import streamlit as st
|
21 |
|
22 |
|
23 |
from rtvc.encoder import inference as encoder
|
|
|
117 |
return base64.b64encode(result_bytes).decode()
|
118 |
|
119 |
if __name__ == "__main__":
|
120 |
+
text = "Adkins was raised by a young single mother in various working-class neighbourhoods of London."
|
121 |
embed_name = "Adele"
|
122 |
nlp = spacy.load('en_core_web_sm')
|
123 |
+
b64 = tts(text, embed_name, nlp, autoplay=False)
|
124 |
+
|
125 |
+
md = f"""
|
126 |
+
<audio controls autoplay>
|
127 |
+
<source src="data:audio/wav;base64,{b64}" type="audio/wav">
|
128 |
+
Your browser does not support the audio element.
|
129 |
+
</audio>
|
130 |
+
"""
|
131 |
+
st.markdown(md, unsafe_allow_html=True)
|