Commit
·
7ceef69
1
Parent(s):
2927abc
Updated requirements
Browse files- main.py +4 -3
- requirements.txt +1 -2
main.py
CHANGED
|
@@ -34,9 +34,10 @@ def translate():
|
|
| 34 |
|
| 35 |
# Recognize speech in the selected language
|
| 36 |
try:
|
| 37 |
-
|
| 38 |
-
translated_text = translator.translate(
|
| 39 |
-
|
|
|
|
| 40 |
except Exception as e:
|
| 41 |
return jsonify({"error": str(e)})
|
| 42 |
|
|
|
|
| 34 |
|
| 35 |
# Recognize speech in the selected language
|
| 36 |
try:
|
| 37 |
+
ori_text = recognizer.recognize_google(audio, language=recognition_lang)
|
| 38 |
+
translated_text = translator.translate(ori_text, src=src_lang, dest=dest_lang)
|
| 39 |
+
print(f"Translated Text: {translated_text.text}")
|
| 40 |
+
return jsonify({"original": ori_text, "translation": translated_text.text})
|
| 41 |
except Exception as e:
|
| 42 |
return jsonify({"error": str(e)})
|
| 43 |
|
requirements.txt
CHANGED
|
@@ -8,5 +8,4 @@ flask
|
|
| 8 |
flask_compress
|
| 9 |
SpeechRecognition
|
| 10 |
googletrans==3.1.0a0
|
| 11 |
-
|
| 12 |
-
# pyaudio
|
|
|
|
| 8 |
flask_compress
|
| 9 |
SpeechRecognition
|
| 10 |
googletrans==3.1.0a0
|
| 11 |
+
pyaudio
|
|
|