NikilDGr8 commited on
Commit
907f6f0
1 Parent(s): 8593387

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import gradio as gr
2
  import assemblyai as aai
3
  import os
@@ -9,8 +12,9 @@ aai.settings.api_key = "62acec891bb04c339ec059b738bedac6"
9
  def transcribe_audio(audio):
10
  # Save the recorded audio to a file
11
  audio_path = "recorded_audio.wav"
12
- audio.save(audio_path)
13
-
 
14
  # Transcribe the audio file using AssemblyAI
15
  transcriber = aai.Transcriber()
16
  transcript = transcriber.transcribe(audio_path)
@@ -26,7 +30,7 @@ with gr.Blocks() as demo:
26
  gr.Markdown("# Audio Transcription App")
27
  with gr.Row():
28
  with gr.Column():
29
- audio_input = gr.Audio(source="microphone", type="file", label="Record your audio")
30
  output_text = gr.Textbox(label="Transcription")
31
  with gr.Column():
32
  transcribe_button = gr.Button("Transcribe")
 
1
+ # First, ensure the necessary packages are installed:
2
+ # pip install -U assemblyai gradio
3
+
4
  import gradio as gr
5
  import assemblyai as aai
6
  import os
 
12
  def transcribe_audio(audio):
13
  # Save the recorded audio to a file
14
  audio_path = "recorded_audio.wav"
15
+ with open(audio_path, "wb") as f:
16
+ f.write(audio)
17
+
18
  # Transcribe the audio file using AssemblyAI
19
  transcriber = aai.Transcriber()
20
  transcript = transcriber.transcribe(audio_path)
 
30
  gr.Markdown("# Audio Transcription App")
31
  with gr.Row():
32
  with gr.Column():
33
+ audio_input = gr.Audio(type="filepath", label="Record your audio")
34
  output_text = gr.Textbox(label="Transcription")
35
  with gr.Column():
36
  transcribe_button = gr.Button("Transcribe")