Commit
·
bcd12d6
1
Parent(s):
9c39d43
no memory no fr for faster execution
Browse files
app.py
CHANGED
|
@@ -80,7 +80,7 @@ def complete_prompt(input_text):
|
|
| 80 |
response = llm(formatted_prompt, max_tokens=80, temperature=0, top_p=0.95, top_k=10)
|
| 81 |
text_response = response["choices"][0]["text"]
|
| 82 |
token_count += response["usage"]["total_tokens"]
|
| 83 |
-
memory = f"Prompt: {contextual_prompt}\nResponse: {text_response}"
|
| 84 |
with open(os.path.join(OUTPUT_PATH, "LLM_response.txt"), 'w') as file:
|
| 85 |
file.write(memory)
|
| 86 |
return text_response
|
|
@@ -154,10 +154,17 @@ def convert_text_to_speech(text):
|
|
| 154 |
tts = gTTS(text, lang=LANGUAGE, tld=tld)
|
| 155 |
tts.save(file_path)
|
| 156 |
elif tts_method == "Custom TTS":
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
return file_path
|
| 163 |
|
|
@@ -198,7 +205,7 @@ with gr.Blocks(title="Whisper-LLM-TTS") as app:
|
|
| 198 |
|
| 199 |
with gr.Row():
|
| 200 |
with gr.Column():
|
| 201 |
-
language_switch = gr.Radio(choices=["en"
|
| 202 |
language_switch.change(update_language, inputs=[language_switch])
|
| 203 |
with gr.Column():
|
| 204 |
tts_method_switch = gr.Radio(choices=["gTTS", "Custom TTS"], label="Select TTS method", value=tts_method)
|
|
|
|
| 80 |
response = llm(formatted_prompt, max_tokens=80, temperature=0, top_p=0.95, top_k=10)
|
| 81 |
text_response = response["choices"][0]["text"]
|
| 82 |
token_count += response["usage"]["total_tokens"]
|
| 83 |
+
#memory = f"Prompt: {contextual_prompt}\nResponse: {text_response}"
|
| 84 |
with open(os.path.join(OUTPUT_PATH, "LLM_response.txt"), 'w') as file:
|
| 85 |
file.write(memory)
|
| 86 |
return text_response
|
|
|
|
| 154 |
tts = gTTS(text, lang=LANGUAGE, tld=tld)
|
| 155 |
tts.save(file_path)
|
| 156 |
elif tts_method == "Custom TTS":
|
| 157 |
+
if LANGUAGE == "fr":
|
| 158 |
+
tld = "fr"
|
| 159 |
+
elif LANGUAGE == "en":
|
| 160 |
+
tld = "us"
|
| 161 |
+
tts = gTTS(text, lang=LANGUAGE, tld=tld)
|
| 162 |
+
tts.save(file_path)
|
| 163 |
+
|
| 164 |
+
# tts_pipeline = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech")
|
| 165 |
+
# speech = tts_pipeline(text)
|
| 166 |
+
# with open(file_path, "wb") as f:
|
| 167 |
+
# f.write(speech["speech"])
|
| 168 |
|
| 169 |
return file_path
|
| 170 |
|
|
|
|
| 205 |
|
| 206 |
with gr.Row():
|
| 207 |
with gr.Column():
|
| 208 |
+
language_switch = gr.Radio(choices=["en"], label="Select Language", value=LANGUAGE)
|
| 209 |
language_switch.change(update_language, inputs=[language_switch])
|
| 210 |
with gr.Column():
|
| 211 |
tts_method_switch = gr.Radio(choices=["gTTS", "Custom TTS"], label="Select TTS method", value=tts_method)
|