rajsecrets0 commited on
Commit
7a36f6b
·
verified ·
1 Parent(s): 4831a61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -9
app.py CHANGED
@@ -7,10 +7,7 @@ import librosa
7
  import soundfile as sf
8
 
9
  def convert_to_wav(audio_file):
10
- # Load the audio file
11
  y, sr = librosa.load(audio_file, sr=None)
12
-
13
- # Create a temporary WAV file
14
  with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as tmp_wav:
15
  sf.write(tmp_wav.name, y, sr, format='wav')
16
  return tmp_wav.name
@@ -38,21 +35,16 @@ def main():
38
  tmp_file_path = tmp_file.name
39
 
40
  try:
41
- # Convert to WAV
42
  wav_file_path = convert_to_wav(tmp_file_path)
43
-
44
- # Transcribe
45
  transcription = transcribe_audio(wav_file_path)
46
-
47
  st.write("Transcription:")
48
  st.write(transcription)
49
  except Exception as e:
50
  st.error(f"An error occurred: {str(e)}")
51
  finally:
52
- # Clean up
53
  os.unlink(tmp_file_path)
54
  if 'wav_file_path' in locals():
55
  os.unlink(wav_file_path)
56
 
57
  if __name__ == "__main__":
58
- main()
 
7
  import soundfile as sf
8
 
9
  def convert_to_wav(audio_file):
 
10
  y, sr = librosa.load(audio_file, sr=None)
 
 
11
  with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as tmp_wav:
12
  sf.write(tmp_wav.name, y, sr, format='wav')
13
  return tmp_wav.name
 
35
  tmp_file_path = tmp_file.name
36
 
37
  try:
 
38
  wav_file_path = convert_to_wav(tmp_file_path)
 
 
39
  transcription = transcribe_audio(wav_file_path)
 
40
  st.write("Transcription:")
41
  st.write(transcription)
42
  except Exception as e:
43
  st.error(f"An error occurred: {str(e)}")
44
  finally:
 
45
  os.unlink(tmp_file_path)
46
  if 'wav_file_path' in locals():
47
  os.unlink(wav_file_path)
48
 
49
  if __name__ == "__main__":
50
+ main()