Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -32,15 +32,13 @@ def loadfile():
|
|
32 |
with open(local_filename, 'rb') as audio_file:
|
33 |
files = {'file': audio_file}
|
34 |
upload_response = requests.post(upload_url, files=files)
|
35 |
-
print(f"Đường dẫn tệp đã tách: {upload_response}")
|
36 |
-
|
37 |
# Xử lý phản hồi từ server sau khi upload
|
38 |
if upload_response.status_code == 200:
|
39 |
result = upload_response.json()
|
40 |
-
print(f"Đường dẫn tệp đã tách: {result}")
|
41 |
# Lấy đường dẫn của tệp đã upload
|
42 |
if isinstance(result, list) and result:
|
43 |
file_url = result[0]
|
|
|
44 |
extracted_path = os.path.dirname(file_url)
|
45 |
print(f"Đường dẫn tệp đã tách: {extracted_path}")
|
46 |
else:
|
@@ -50,7 +48,8 @@ def loadfile():
|
|
50 |
os.remove(local_filename)
|
51 |
else:
|
52 |
print(f"Lỗi khi tải tệp từ URL: {response.status_code}")
|
53 |
-
|
|
|
54 |
# Step 1: Transcribe the audio file
|
55 |
def transcribe_audio(audio):
|
56 |
if audio is None:
|
@@ -141,7 +140,7 @@ def compare_texts(reference_text, transcribed_text):
|
|
141 |
def text_to_speech(paragraph):
|
142 |
if not paragraph:
|
143 |
return None # Handle the case when no text is provided
|
144 |
-
|
145 |
tts = gTTS(paragraph)
|
146 |
audio_file_path = "audio/paragraph.mp3" # Save the audio to a file
|
147 |
tts.save(audio_file_path)
|
|
|
32 |
with open(local_filename, 'rb') as audio_file:
|
33 |
files = {'file': audio_file}
|
34 |
upload_response = requests.post(upload_url, files=files)
|
|
|
|
|
35 |
# Xử lý phản hồi từ server sau khi upload
|
36 |
if upload_response.status_code == 200:
|
37 |
result = upload_response.json()
|
|
|
38 |
# Lấy đường dẫn của tệp đã upload
|
39 |
if isinstance(result, list) and result:
|
40 |
file_url = result[0]
|
41 |
+
print(f"Đường dẫn tệp đã tách: {file_url}")
|
42 |
extracted_path = os.path.dirname(file_url)
|
43 |
print(f"Đường dẫn tệp đã tách: {extracted_path}")
|
44 |
else:
|
|
|
48 |
os.remove(local_filename)
|
49 |
else:
|
50 |
print(f"Lỗi khi tải tệp từ URL: {response.status_code}")
|
51 |
+
|
52 |
+
loadfile()
|
53 |
# Step 1: Transcribe the audio file
|
54 |
def transcribe_audio(audio):
|
55 |
if audio is None:
|
|
|
140 |
def text_to_speech(paragraph):
|
141 |
if not paragraph:
|
142 |
return None # Handle the case when no text is provided
|
143 |
+
|
144 |
tts = gTTS(paragraph)
|
145 |
audio_file_path = "audio/paragraph.mp3" # Save the audio to a file
|
146 |
tts.save(audio_file_path)
|