lhzstar commited on
Commit
a034be6
1 Parent(s): a0194f4

new commits

Browse files
Files changed (3) hide show
  1. app.py +1 -2
  2. celebbot.py +1 -1
  3. 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 style="display:none;">
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} Question: {self.text} Answer:"
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. As a child, she enjoyed singing contemporary pop music and learned to play the guitar and the clarinet. However, it was not until her early teens, when she discovered rhythm-and-blues singer Etta James and other mid-20th-century performers, that she began to consider a musical career. While she honed her talents at a government-funded secondary school for the performing arts, a friend began posting songs Adkins had written and recorded onto the social networking Web site Myspace. Her music eventually caught the attention of record labels, and in 2006, several months after graduating, she signed a contract with XL Recordings."
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)