mr2along commited on
Commit
f975491
verified
1 Parent(s): 84f7df5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -7,6 +7,7 @@ from gtts import gTTS
7
  import io
8
  from pydub import AudioSegment
9
  import time
 
10
  # Create audio directory if it doesn't exist
11
  if not os.path.exists('audio'):
12
  os.makedirs('audio')
@@ -17,7 +18,7 @@ def transcribe_audio(audio):
17
  return "No audio file provided."
18
 
19
  recognizer = sr.Recognizer()
20
-
21
  # Check if the file exists
22
  if not os.path.isfile(audio):
23
  return "Audio file not found."
@@ -55,14 +56,10 @@ def upfilepath(local_filename):
55
  response = requests.post(upload_url, files=files, timeout=30) # Set timeout (e.g., 30 seconds)
56
 
57
  if response.status_code == 200:
58
- #print("Upload th脿nh c么ng!")
59
  result = response.json()
60
  extracted_path = result[0]
61
- print(extracted_path)
62
  return extracted_path
63
  else:
64
- print(f"L峄梚: {response.status_code}")
65
- print(response.text)
66
  return None
67
 
68
  except requests.exceptions.Timeout:
@@ -185,4 +182,4 @@ tts_interface = gr.Interface(
185
  demo = gr.TabbedInterface([interface, tts_interface], ["Speech Recognition", "Text-to-Speech"])
186
 
187
  # Launch Gradio app
188
- demo.launch()
 
7
  import io
8
  from pydub import AudioSegment
9
  import time
10
+
11
  # Create audio directory if it doesn't exist
12
  if not os.path.exists('audio'):
13
  os.makedirs('audio')
 
18
  return "No audio file provided."
19
 
20
  recognizer = sr.Recognizer()
21
+
22
  # Check if the file exists
23
  if not os.path.isfile(audio):
24
  return "Audio file not found."
 
56
  response = requests.post(upload_url, files=files, timeout=30) # Set timeout (e.g., 30 seconds)
57
 
58
  if response.status_code == 200:
 
59
  result = response.json()
60
  extracted_path = result[0]
 
61
  return extracted_path
62
  else:
 
 
63
  return None
64
 
65
  except requests.exceptions.Timeout:
 
182
  demo = gr.TabbedInterface([interface, tts_interface], ["Speech Recognition", "Text-to-Speech"])
183
 
184
  # Launch Gradio app
185
+ demo.launch()