Merlintxu commited on
Commit
3b1a6b5
1 Parent(s): 2c14509

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -38,7 +38,7 @@ def convert_audio_to_wav(audio_path):
38
  raise ValueError(f"The path provided is a directory, not a file: {audio_path}")
39
  wav_path = "converted_audio.wav"
40
  command = ["ffmpeg", "-i", audio_path, "-ac", "1", "-ar", "16000", wav_path]
41
- subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
42
  return wav_path
43
 
44
  def detect_language(audio_path):
@@ -125,7 +125,7 @@ def save_transcription(transcriptions, file_format):
125
  file_path = "transcription.txt"
126
  with open(file_path, 'w') as f:
127
  for entry in transcriptions:
128
- f.write(f"{entry['start_time']},{entry['end_time']},{entry['text']}\n")
129
  return file_path
130
 
131
  def combined_interface(audio, file_format):
@@ -157,7 +157,7 @@ def combined_interface(audio, file_format):
157
  iface = gr.Interface(
158
  fn=combined_interface,
159
  inputs=[
160
- gr.Audio(type="filepath"),
161
  gr.Radio(choices=["JSON", "TXT"], label="Choose output format")
162
  ],
163
  outputs=[
@@ -175,4 +175,4 @@ iface = gr.Interface(
175
  )
176
 
177
  if __name__ == "__main__":
178
- iface.queue().launch()
 
38
  raise ValueError(f"The path provided is a directory, not a file: {audio_path}")
39
  wav_path = "converted_audio.wav"
40
  command = ["ffmpeg", "-i", audio_path, "-ac", "1", "-ar", "16000", wav_path]
41
+ subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
42
  return wav_path
43
 
44
  def detect_language(audio_path):
 
125
  file_path = "transcription.txt"
126
  with open(file_path, 'w') as f:
127
  for entry in transcriptions:
128
+ f.write(f"{entry['start_time']:.2f},{entry['end_time']:.2f},{entry['text']}\n")
129
  return file_path
130
 
131
  def combined_interface(audio, file_format):
 
157
  iface = gr.Interface(
158
  fn=combined_interface,
159
  inputs=[
160
+ gr.Audio(type="filepath", label="Upload Audio File"),
161
  gr.Radio(choices=["JSON", "TXT"], label="Choose output format")
162
  ],
163
  outputs=[
 
175
  )
176
 
177
  if __name__ == "__main__":
178
+ iface.queue().launch()