Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -62,7 +62,7 @@ def generate_llm_response(text, model_id="ccibeekeoc42/Llama3.1-8b-base-SFT-2024
|
|
62 |
else:
|
63 |
raise e
|
64 |
|
65 |
-
generate_llm_response("Explain Deep Learning in Igbo")
|
66 |
|
67 |
|
68 |
# Loading the ST Model (Whisper) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
@@ -186,11 +186,11 @@ def replace_numbers_with_words(text, lang="en"):
|
|
186 |
# Replace all numbers in the text
|
187 |
return re.sub(r'\b\d+\b', replace, text)
|
188 |
|
189 |
-
llm_response = generate_llm_response("Explain Deep Learning in Igbo")
|
190 |
-
llm_response_cleaned = normalize_text(cleanup_text(replace_numbers_with_words(llm_response, "yo"), "yo"))
|
191 |
|
192 |
-
print(f"LLM Response: {llm_response}")
|
193 |
-
print(f"LLM Response Cleaned: {llm_response_cleaned}")
|
194 |
|
195 |
# returning spech from text (and bringing to CPU)
|
196 |
def synthesise(text):
|
@@ -214,14 +214,17 @@ def speech_to_speech_translation(audio):
|
|
214 |
print(f"Transcribed: {transcribed_text}")
|
215 |
|
216 |
# Generate LLM Response
|
|
|
217 |
llm_response = generate_llm_response(transcribed_text)
|
218 |
llm_response_cleaned = normalize_text(cleanup_text(replace_numbers_with_words(llm_response, "yo"), "yo"))
|
219 |
print(f"LLM Response: {llm_response}")
|
220 |
print(f"LLM Response Cleaned: {llm_response_cleaned}")
|
221 |
|
222 |
# Text to Speech
|
|
|
223 |
synthesised_speech = synthesise(llm_response_cleaned)
|
224 |
synthesised_speech = (synthesised_speech.numpy() * max_range).astype(np.int16)
|
|
|
225 |
|
226 |
return transcribed_text, (16000, synthesised_speech), llm_response
|
227 |
|
|
|
62 |
else:
|
63 |
raise e
|
64 |
|
65 |
+
# generate_llm_response("Explain Deep Learning in Igbo")
|
66 |
|
67 |
|
68 |
# Loading the ST Model (Whisper) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
186 |
# Replace all numbers in the text
|
187 |
return re.sub(r'\b\d+\b', replace, text)
|
188 |
|
189 |
+
# llm_response = generate_llm_response("Explain Deep Learning in Igbo")
|
190 |
+
# llm_response_cleaned = normalize_text(cleanup_text(replace_numbers_with_words(llm_response, "yo"), "yo"))
|
191 |
|
192 |
+
# print(f"LLM Response: {llm_response}")
|
193 |
+
# print(f"LLM Response Cleaned: {llm_response_cleaned}")
|
194 |
|
195 |
# returning spech from text (and bringing to CPU)
|
196 |
def synthesise(text):
|
|
|
214 |
print(f"Transcribed: {transcribed_text}")
|
215 |
|
216 |
# Generate LLM Response
|
217 |
+
print("Now making LLM Call ~~~~~~~~~~~~~~~~~~~~~~~~")
|
218 |
llm_response = generate_llm_response(transcribed_text)
|
219 |
llm_response_cleaned = normalize_text(cleanup_text(replace_numbers_with_words(llm_response, "yo"), "yo"))
|
220 |
print(f"LLM Response: {llm_response}")
|
221 |
print(f"LLM Response Cleaned: {llm_response_cleaned}")
|
222 |
|
223 |
# Text to Speech
|
224 |
+
print("Synthesizing Speech ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
|
225 |
synthesised_speech = synthesise(llm_response_cleaned)
|
226 |
synthesised_speech = (synthesised_speech.numpy() * max_range).astype(np.int16)
|
227 |
+
print("Speech Synthesis Completed~~~~~~~~~~~~~~~~~~~")
|
228 |
|
229 |
return transcribed_text, (16000, synthesised_speech), llm_response
|
230 |
|