Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import gradio as gr
|
|
| 3 |
import whisper
|
| 4 |
from gtts import gTTS
|
| 5 |
from groq import Groq
|
| 6 |
-
import numpy as np
|
| 7 |
|
| 8 |
# Load the Groq API key from the environment variable
|
| 9 |
api_key = os.getenv("GROQ_API_KEY")
|
|
@@ -21,8 +20,9 @@ def chatbot(audio_input):
|
|
| 21 |
if audio_input is None:
|
| 22 |
raise ValueError("Audio input is None. Please provide a valid audio file.")
|
| 23 |
|
| 24 |
-
# Step 1:
|
| 25 |
-
|
|
|
|
| 26 |
if transcription_result is None or not transcription_result.get("text"):
|
| 27 |
raise ValueError("Whisper transcription failed or returned empty text.")
|
| 28 |
|
|
|
|
| 3 |
import whisper
|
| 4 |
from gtts import gTTS
|
| 5 |
from groq import Groq
|
|
|
|
| 6 |
|
| 7 |
# Load the Groq API key from the environment variable
|
| 8 |
api_key = os.getenv("GROQ_API_KEY")
|
|
|
|
| 20 |
if audio_input is None:
|
| 21 |
raise ValueError("Audio input is None. Please provide a valid audio file.")
|
| 22 |
|
| 23 |
+
# Step 1: Load and transcribe audio input using Whisper
|
| 24 |
+
audio = whisper.load_audio(audio_input)
|
| 25 |
+
transcription_result = whisper_model.transcribe(audio)
|
| 26 |
if transcription_result is None or not transcription_result.get("text"):
|
| 27 |
raise ValueError("Whisper transcription failed or returned empty text.")
|
| 28 |
|