mr2along commited on
Commit
11a3c0d
1 Parent(s): b876138

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -42,7 +42,7 @@ def upfilepath():
42
  else:
43
  print(f"Lỗi: {response.status_code}")
44
  print(response.text) # In thông báo lỗi từ server
45
- upfilepath()
46
  # Step 1: Transcribe the audio file
47
  def transcribe_audio(audio):
48
  if audio is None:
@@ -81,10 +81,11 @@ def transcribe_audio(audio):
81
  def create_pronunciation_audio(word):
82
  time.sleep(5) # Chờ 5 giây
83
  tts = gTTS(word)
 
84
  audio_file_path = f"audio/{word}.mp3" # Save the audio to a file
85
  tts.save(audio_file_path)
86
  print(f"audio/{word}: {(os.path.abspath(audio_file_path))}")
87
- return audio_file_path # Return the file path of the saved audio
88
 
89
  # Step 3: Compare the transcribed text with the input paragraph
90
  def compare_texts(reference_text, transcribed_text):
@@ -142,7 +143,7 @@ def text_to_speech(paragraph):
142
  # Gradio Interface Function
143
  def gradio_function(paragraph, audio):
144
  # Transcribe the audio
145
- filePath=upfilepath()
146
  transcribed_text = transcribe_audio(audio)
147
 
148
  # Compare the original paragraph with the transcribed text
 
42
  else:
43
  print(f"Lỗi: {response.status_code}")
44
  print(response.text) # In thông báo lỗi từ server
45
+ filePath=upfilepath()
46
  # Step 1: Transcribe the audio file
47
  def transcribe_audio(audio):
48
  if audio is None:
 
81
  def create_pronunciation_audio(word):
82
  time.sleep(5) # Chờ 5 giây
83
  tts = gTTS(word)
84
+ main_url="https://mr2along-speech-recognize.hf.space/gradio_api/file="
85
  audio_file_path = f"audio/{word}.mp3" # Save the audio to a file
86
  tts.save(audio_file_path)
87
  print(f"audio/{word}: {(os.path.abspath(audio_file_path))}")
88
+ return f"{main_url}{filePath}/{audio_file_path}" # Return the file path of the saved audio
89
 
90
  # Step 3: Compare the transcribed text with the input paragraph
91
  def compare_texts(reference_text, transcribed_text):
 
143
  # Gradio Interface Function
144
  def gradio_function(paragraph, audio):
145
  # Transcribe the audio
146
+
147
  transcribed_text = transcribe_audio(audio)
148
 
149
  # Compare the original paragraph with the transcribed text