Spaces:
Build error
Build error
Commit
·
cbe1d96
1
Parent(s):
586a110
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,6 @@ from itertools import chain
|
|
7 |
|
8 |
import os
|
9 |
|
10 |
-
import tempfile
|
11 |
-
from typing import Optional
|
12 |
-
from TTS.config import load_config
|
13 |
-
import numpy as np
|
14 |
-
from TTS.utils.manage import ModelManager
|
15 |
-
from TTS.utils.synthesizer import Synthesizer
|
16 |
-
|
17 |
#emotion_tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-emotion")
|
18 |
#emotion_model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-emotion")
|
19 |
|
@@ -111,60 +104,8 @@ def get_chat_response(name,history=[], input_txt = "Hello , what is your name?")
|
|
111 |
MODEL_NAME= "tts_models/multilingual/multi-dataset/your_tts"
|
112 |
|
113 |
|
|
|
114 |
|
115 |
-
def greet(character,your_voice,message,history):
|
116 |
-
|
117 |
-
#gradios set_state/get_state had problems on embedded html!
|
118 |
-
history = history or {"character": character, "message_history" : [] }
|
119 |
-
#gradios set_state/get_state does not persist session for now using global
|
120 |
-
#global history
|
121 |
-
|
122 |
-
if history["character"] != character:
|
123 |
-
#switching character
|
124 |
-
history = {"character": character, "message_history" : [] }
|
125 |
-
|
126 |
-
|
127 |
-
response = get_chat_response(character,history=history["message_history"],input_txt=message)
|
128 |
-
os.system('tts --text "'+response+'" --model_name tts_models/multilingual/multi-dataset/your_tts --speaker_wav '+your_voice+' --language_idx "en"')
|
129 |
-
|
130 |
-
history["message_history"].append((message, response))
|
131 |
-
|
132 |
-
#emotion = get_emotion(response)
|
133 |
-
|
134 |
-
html = "<div class='chatbot'>"
|
135 |
-
for user_msg, resp_msg in history["message_history"]:
|
136 |
-
html += f"<div class='user_msg'>You: {user_msg}</div>"
|
137 |
-
html += f"<div class='resp_msg'>{character}: {resp_msg}</div>"
|
138 |
-
html += "</div>"
|
139 |
-
|
140 |
-
return html,history,"tts_output.wav"
|
141 |
-
|
142 |
-
|
143 |
-
def greet_textonly(character,message,history):
|
144 |
-
|
145 |
-
#gradios set_state/get_state had problems on embedded html!
|
146 |
-
history = history or {"character": character, "message_history" : [] }
|
147 |
-
#gradios set_state/get_state does not persist session for now using global
|
148 |
-
#global history
|
149 |
-
|
150 |
-
if history["character"] != character:
|
151 |
-
#switching character
|
152 |
-
history = {"character": character, "message_history" : [] }
|
153 |
-
|
154 |
-
|
155 |
-
response = get_chat_response(character,history=history["message_history"],input_txt=message)
|
156 |
-
|
157 |
-
history["message_history"].append((message, response))
|
158 |
-
|
159 |
-
#emotion = get_emotion(response)
|
160 |
-
|
161 |
-
html = "<div class='chatbot'>"
|
162 |
-
for user_msg, resp_msg in history["message_history"]:
|
163 |
-
html += f"<div class='user_msg'>You: {user_msg}</div>"
|
164 |
-
html += f"<div class='resp_msg'>{character}: {resp_msg}</div>"
|
165 |
-
html += "</div>"
|
166 |
-
|
167 |
-
return html,history
|
168 |
|
169 |
|
170 |
personality_choices = ["Gandalf", "Riddick", "Macleod", "Morpheus", "Neo","Spock","Vader","Indy"]
|
@@ -192,8 +133,19 @@ examples=[['Gandalf','dragon.wav','Who are you sir?',{}]]
|
|
192 |
|
193 |
history = {"character": "None", "message_history" : [] }
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
interface_mic= gr.Interface.load("gorkemgoknar/movie_chat_gpt_yourtts",
|
196 |
-
|
197 |
inputs=[gr.inputs.Dropdown(personality_choices),
|
198 |
gr.inputs.Audio(source="microphone", type="filepath") ,
|
199 |
"text",
|
|
|
7 |
|
8 |
import os
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
#emotion_tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-emotion")
|
11 |
#emotion_model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-emotion")
|
12 |
|
|
|
104 |
MODEL_NAME= "tts_models/multilingual/multi-dataset/your_tts"
|
105 |
|
106 |
|
107 |
+
## SEE https://huggingface.co/spaces/gorkemgoknar/movie_chat_gpt_yourtts_fileinput for actual call
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
|
111 |
personality_choices = ["Gandalf", "Riddick", "Macleod", "Morpheus", "Neo","Spock","Vader","Indy"]
|
|
|
133 |
|
134 |
history = {"character": "None", "message_history" : [] }
|
135 |
|
136 |
+
|
137 |
+
interface_file= gr.Interface.load("gorkemgoknar/movie_chat_gpt_yourtts_fileinput",
|
138 |
+
src="spaces",
|
139 |
+
inputs=[gr.inputs.Dropdown(personality_choices),
|
140 |
+
gr.inputs.Audio(type="filepath"),
|
141 |
+
"text",
|
142 |
+
"state"],
|
143 |
+
outputs=["html","state",gr.outputs.Audio(type="file")],
|
144 |
+
css=css, title=title, description=description,article=article )
|
145 |
+
|
146 |
+
|
147 |
interface_mic= gr.Interface.load("gorkemgoknar/movie_chat_gpt_yourtts",
|
148 |
+
src="spaces",
|
149 |
inputs=[gr.inputs.Dropdown(personality_choices),
|
150 |
gr.inputs.Audio(source="microphone", type="filepath") ,
|
151 |
"text",
|