Dental_LLM / app.py
NikilDGr8's picture
Update app.py
4e4575b verified
raw
history blame
1.55 kB
# First, ensure the necessary packages are installed:
# pip install -U assemblyai gradio
import gradio as gr
import assemblyai as aai
# Replace with your AssemblyAI API key
aai.settings.api_key = "62acec891bb04c339ec059b738bedac6"
# Function to handle audio recording and transcription
def transcribe_audio(audio_path):
print(f"Received audio file at: {audio_path}")
try:
# Transcribe the audio file using AssemblyAI
transcriber = aai.Transcriber()
print("Starting transcription...")
transcript = transcriber.transcribe(audio_path)
print("Transcription process completed.")
# Handle the transcription result
if transcript.status == aai.TranscriptStatus.error:
print(f"Error during transcription: {transcript.error}")
return transcript.error
else:
print(f"Transcription text: {transcript.text}")
return transcript.text
except Exception as e:
print(f"Exception occurred: {e}")
return str(e)
# Create the Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# Audio Transcription App")
with gr.Row():
with gr.Column():
audio_input = gr.Audio(type="filepath", label="Record your audio")
output_text = gr.Textbox(label="Transcription")
with gr.Column():
transcribe_button = gr.Button("Transcribe")
transcribe_button.click(fn=transcribe_audio, inputs=audio_input, outputs=output_text)
# Launch the app
demo.launch()