Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,9 +31,9 @@ def load_whisper():
|
|
| 31 |
return whisper.load_model("medium", device = 'cpu')
|
| 32 |
|
| 33 |
def load_tts():
|
| 34 |
-
tts_model = VitsModel.from_pretrained("facebook/mms-tts-
|
| 35 |
#tts_model.to("cuda")
|
| 36 |
-
tokenizer_tss = AutoTokenizer.from_pretrained("facebook/mms-tts-
|
| 37 |
return tts_model, tokenizer_tss
|
| 38 |
|
| 39 |
|
|
@@ -109,7 +109,7 @@ def predict(_query, _chatbot, _task_history):
|
|
| 109 |
_chatbot.append((_parse_text(_query), ""))
|
| 110 |
full_response = ""
|
| 111 |
|
| 112 |
-
for response in model.chat_stream(tokenizer, _query, history=_task_history,system = "
|
| 113 |
_chatbot[-1] = (_parse_text(_query), _parse_text(response))
|
| 114 |
|
| 115 |
yield _chatbot
|
|
@@ -134,7 +134,7 @@ def update_audio(text):
|
|
| 134 |
|
| 135 |
|
| 136 |
def translate(audio):
|
| 137 |
-
print("
|
| 138 |
transcription = whisper_model.transcribe(audio, language="pl")
|
| 139 |
return transcription["text"]
|
| 140 |
|
|
@@ -179,10 +179,8 @@ with gr.Blocks() as demo:
|
|
| 179 |
query = gr.Textbox(lines=2, label='Input')
|
| 180 |
task_history = gr.State([])
|
| 181 |
audio_output = gr.Audio('temp_file.wav', label="Generated Audio (wav)", type='filepath', autoplay=False)
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
submit_btn = gr.Button("🚀 Send an input file to LLM")
|
| 185 |
-
|
| 186 |
with gr.Row():
|
| 187 |
audio_upload = gr.Audio(sources="microphone", type="filepath", show_label=False)
|
| 188 |
submit_audio_btn = gr.Button("🎙️ Send an audio")
|
|
|
|
| 31 |
return whisper.load_model("medium", device = 'cpu')
|
| 32 |
|
| 33 |
def load_tts():
|
| 34 |
+
tts_model = VitsModel.from_pretrained("facebook/mms-tts-eng")
|
| 35 |
#tts_model.to("cuda")
|
| 36 |
+
tokenizer_tss = AutoTokenizer.from_pretrained("facebook/mms-tts-eng")
|
| 37 |
return tts_model, tokenizer_tss
|
| 38 |
|
| 39 |
|
|
|
|
| 109 |
_chatbot.append((_parse_text(_query), ""))
|
| 110 |
full_response = ""
|
| 111 |
|
| 112 |
+
for response in model.chat_stream(tokenizer, _query, history=_task_history,system = "You are an AI assistant. Please be kind and answer responsibly." ):
|
| 113 |
_chatbot[-1] = (_parse_text(_query), _parse_text(response))
|
| 114 |
|
| 115 |
yield _chatbot
|
|
|
|
| 134 |
|
| 135 |
|
| 136 |
def translate(audio):
|
| 137 |
+
print("__Sending audio to stt model")
|
| 138 |
transcription = whisper_model.transcribe(audio, language="pl")
|
| 139 |
return transcription["text"]
|
| 140 |
|
|
|
|
| 179 |
query = gr.Textbox(lines=2, label='Input')
|
| 180 |
task_history = gr.State([])
|
| 181 |
audio_output = gr.Audio('temp_file.wav', label="Generated Audio (wav)", type='filepath', autoplay=False)
|
| 182 |
+
# with gr.Row():
|
| 183 |
+
# submit_btn = gr.Button("🚀 Send an input file to LLM")
|
|
|
|
|
|
|
| 184 |
with gr.Row():
|
| 185 |
audio_upload = gr.Audio(sources="microphone", type="filepath", show_label=False)
|
| 186 |
submit_audio_btn = gr.Button("🎙️ Send an audio")
|