Update main.py
Browse files
main.py
CHANGED
@@ -64,13 +64,13 @@ def transcribe(audio_path):
|
|
64 |
result = whisper.decode(model, mel, options)
|
65 |
|
66 |
print(" Transcription complete.", flush=True)
|
67 |
-
return result.text, language
|
68 |
|
69 |
@app.route('/transcribe', methods=['POST'])
|
70 |
def transcribe_audio():
|
71 |
# Record the time when the request was received
|
72 |
request_received_time, _ = get_time()
|
73 |
-
print(f"Query
|
74 |
|
75 |
if 'audio' not in request.files:
|
76 |
print("Error: No audio file provided", flush=True)
|
@@ -92,7 +92,7 @@ def transcribe_audio():
|
|
92 |
|
93 |
# Transcribe the audio
|
94 |
try:
|
95 |
-
transcription, language = transcribe(audio_path)
|
96 |
except Exception as e:
|
97 |
print(f" Error during transcription: {str(e)}", flush=True)
|
98 |
return jsonify({"error": f"An error occurred: {str(e)}"}), 500
|
@@ -111,7 +111,7 @@ def transcribe_audio():
|
|
111 |
# Return the transcription, detected language, and timing information
|
112 |
#print(f" Transcription: {transcription}, Language: {language}, Processing Time: {transcription_duration}\n", flush=True)
|
113 |
print(f" \033[92mTranscription: {transcription}, Language: {language}, Processing Time: {transcription_duration}\033[0m\n", flush=True)
|
114 |
-
|
115 |
return jsonify({
|
116 |
"transcription": transcription,
|
117 |
"language": language,
|
|
|
64 |
result = whisper.decode(model, mel, options)
|
65 |
|
66 |
print(" Transcription complete.", flush=True)
|
67 |
+
return result.text, language, result
|
68 |
|
69 |
@app.route('/transcribe', methods=['POST'])
|
70 |
def transcribe_audio():
|
71 |
# Record the time when the request was received
|
72 |
request_received_time, _ = get_time()
|
73 |
+
print(f"Query:- {request_received_time}", flush=True)
|
74 |
|
75 |
if 'audio' not in request.files:
|
76 |
print("Error: No audio file provided", flush=True)
|
|
|
92 |
|
93 |
# Transcribe the audio
|
94 |
try:
|
95 |
+
transcription, language, srt = transcribe(audio_path)
|
96 |
except Exception as e:
|
97 |
print(f" Error during transcription: {str(e)}", flush=True)
|
98 |
return jsonify({"error": f"An error occurred: {str(e)}"}), 500
|
|
|
111 |
# Return the transcription, detected language, and timing information
|
112 |
#print(f" Transcription: {transcription}, Language: {language}, Processing Time: {transcription_duration}\n", flush=True)
|
113 |
print(f" \033[92mTranscription: {transcription}, Language: {language}, Processing Time: {transcription_duration}\033[0m\n", flush=True)
|
114 |
+
#print(srt, flush=True)
|
115 |
return jsonify({
|
116 |
"transcription": transcription,
|
117 |
"language": language,
|