gorkemgoknar commited on
Commit
7b92f0d
1 Parent(s): e58b4b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -114,7 +114,7 @@ MODEL_NAME= "tts_models/multilingual/multi-dataset/your_tts"
114
 
115
 
116
 
117
- def greet(character,your_voice,voice_file,message,history):
118
 
119
  #gradios set_state/get_state had problems on embedded html!
120
  history = history or {"character": character, "message_history" : [] }
@@ -127,10 +127,8 @@ def greet(character,your_voice,voice_file,message,history):
127
 
128
 
129
  response = get_chat_response(character,history=history["message_history"],input_txt=message)
130
- if voice_file is not None:
131
- your_voice = voice_file
132
-
133
- os.system('tts --text "'+response+'" --model_name tts_models/multilingual/multi-dataset/your_tts --speaker_wav '+your_voice+' --language_idx "en"')
134
 
135
  history["message_history"].append((message, response))
136
 
@@ -142,7 +140,7 @@ def greet(character,your_voice,voice_file,message,history):
142
  html += f"<div class='resp_msg'>{character}: {resp_msg}</div>"
143
  html += "</div>"
144
 
145
- return "tts_output.wav", html,history
146
 
147
 
148
 
@@ -170,15 +168,29 @@ article = "<p style='text-align: center'><a href='https://www.linkedin.com/pulse
170
  examples=[['Gandalf','Hello','dragon.wav']]
171
 
172
  history = {"character": "None", "message_history" : [] }
173
- interface= gr.Interface(fn=greet,
 
174
  inputs=[gr.inputs.Dropdown(personality_choices),
175
  gr.inputs.Audio(source="microphone", type="filepath") ,
 
 
 
 
 
 
176
  gr.inputs.Audio(type="filepath"),
177
  "text",
178
  "state"],
179
- outputs=[gr.outputs.Audio(type="file"),"html","state"],
 
 
 
 
 
 
 
180
  css=css, title=title, description=description,article=article )
181
-
182
-
183
  if __name__ == "__main__":
184
  interface.launch()
 
114
 
115
 
116
 
117
+ def greet(character,your_voice,message,history):
118
 
119
  #gradios set_state/get_state had problems on embedded html!
120
  history = history or {"character": character, "message_history" : [] }
 
127
 
128
 
129
  response = get_chat_response(character,history=history["message_history"],input_txt=message)
130
+ if your_voice is not None:
131
+ os.system('tts --text "'+response+'" --model_name tts_models/multilingual/multi-dataset/your_tts --speaker_wav '+your_voice+' --language_idx "en"')
 
 
132
 
133
  history["message_history"].append((message, response))
134
 
 
140
  html += f"<div class='resp_msg'>{character}: {resp_msg}</div>"
141
  html += "</div>"
142
 
143
+ return html,history,"tts_output.wav"
144
 
145
 
146
 
 
168
  examples=[['Gandalf','Hello','dragon.wav']]
169
 
170
  history = {"character": "None", "message_history" : [] }
171
+
172
+ interface_mic= gr.Interface(fn=greet,
173
  inputs=[gr.inputs.Dropdown(personality_choices),
174
  gr.inputs.Audio(source="microphone", type="filepath") ,
175
+ "text",
176
+ "state"],
177
+ outputs=["html","state",gr.outputs.Audio(type="file")],
178
+ css=css, title=title, description=description,article=article )
179
+ interface_file= gr.Interface(fn=greet,
180
+ inputs=[gr.inputs.Dropdown(personality_choices),
181
  gr.inputs.Audio(type="filepath"),
182
  "text",
183
  "state"],
184
+ outputs=["html","state",gr.outputs.Audio(type="file")],
185
+ css=css, title=title, description=description,article=article )
186
+ interface_text= gr.Interface(fn=greet,
187
+ inputs=[gr.inputs.Dropdown(personality_choices),
188
+ None,
189
+ "text",
190
+ "state"],
191
+ outputs=["html","state"],
192
  css=css, title=title, description=description,article=article )
193
+
194
+ appinterface = gr.TabbedInterface([micinput, fileinput, purechat], ["Chat with Record", "Chat with File Upload", "Chat Text only"])
195
  if __name__ == "__main__":
196
  interface.launch()