mr2along commited on
Commit
bb3d1d2
1 Parent(s): 1bda6a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -9,7 +9,6 @@ from pydub import AudioSegment
9
  import time
10
  from phonemizer import phonemize
11
 
12
-
13
  # Create audio directory if it doesn't exist
14
  if not os.path.exists('audio'):
15
  os.makedirs('audio')
@@ -65,13 +64,17 @@ def transcribe_audio(audio):
65
  transcription = recognizer.recognize_google(audio_data)
66
  return transcription
67
  except sr.UnknownValueError:
68
- return "Google Speech Recognition could not understand the audio"
69
  except sr.RequestError as e:
70
  return f"Error with Google Speech Recognition service: {e}"
71
 
72
  # Function to get IPA transcription
73
  def ipa_transcription(sentence):
74
- return phonemize("sentence", language='en-us')
 
 
 
 
75
 
76
  # Step 2: Create pronunciation audio for incorrect words (locally)
77
  def create_pronunciation_audio(word):
 
9
  import time
10
  from phonemizer import phonemize
11
 
 
12
  # Create audio directory if it doesn't exist
13
  if not os.path.exists('audio'):
14
  os.makedirs('audio')
 
64
  transcription = recognizer.recognize_google(audio_data)
65
  return transcription
66
  except sr.UnknownValueError:
67
+ return "Google Speech Recognition could not understand the audio."
68
  except sr.RequestError as e:
69
  return f"Error with Google Speech Recognition service: {e}"
70
 
71
  # Function to get IPA transcription
72
  def ipa_transcription(sentence):
73
+ try:
74
+ ipa = phonemize(sentence, language='en-us', backend='espeak', strip=True)
75
+ return ipa
76
+ except Exception as e:
77
+ return f"Error during IPA transcription: {e}"
78
 
79
  # Step 2: Create pronunciation audio for incorrect words (locally)
80
  def create_pronunciation_audio(word):