NikilDGr8 commited on
Commit
4e4575b
1 Parent(s): 12c3b16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import gradio as gr
2
  import assemblyai as aai
3
 
@@ -6,15 +9,27 @@ aai.settings.api_key = "62acec891bb04c339ec059b738bedac6"
6
 
7
  # Function to handle audio recording and transcription
8
  def transcribe_audio(audio_path):
9
- # Transcribe the audio file using AssemblyAI
10
- transcriber = aai.Transcriber()
11
- transcript = transcriber.transcribe(audio_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- # Handle the transcription result
14
- if transcript.status == aai.TranscriptStatus.error:
15
- return transcript.error
16
- else:
17
- return transcript.text
18
 
19
  # Create the Gradio interface
20
  with gr.Blocks() as demo:
 
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
 
 
9
 
10
  # Function to handle audio recording and transcription
11
  def transcribe_audio(audio_path):
12
+ print(f"Received audio file at: {audio_path}")
13
+
14
+ try:
15
+ # Transcribe the audio file using AssemblyAI
16
+ transcriber = aai.Transcriber()
17
+ print("Starting transcription...")
18
+ transcript = transcriber.transcribe(audio_path)
19
+
20
+ print("Transcription process completed.")
21
+
22
+ # Handle the transcription result
23
+ if transcript.status == aai.TranscriptStatus.error:
24
+ print(f"Error during transcription: {transcript.error}")
25
+ return transcript.error
26
+ else:
27
+ print(f"Transcription text: {transcript.text}")
28
+ return transcript.text
29
 
30
+ except Exception as e:
31
+ print(f"Exception occurred: {e}")
32
+ return str(e)
 
 
33
 
34
  # Create the Gradio interface
35
  with gr.Blocks() as demo: