Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,20 +2,21 @@ import gradio as gr
|
|
2 |
from groq import Groq
|
3 |
import os
|
4 |
import time
|
5 |
-
import
|
6 |
from gtts import gTTS
|
7 |
|
8 |
api_key = os.getenv('GROQ_API_KEY')
|
9 |
# Initialize Groq client
|
10 |
client = Groq(api_key=api_key)
|
11 |
|
|
|
|
|
|
|
12 |
# Function to convert audio to text
|
13 |
def audio_to_text(audio_file):
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
text = recognizer.recognize_google(audio_data)
|
18 |
-
return text
|
19 |
|
20 |
# Function to convert text to audio
|
21 |
def text_to_audio(text):
|
|
|
2 |
from groq import Groq
|
3 |
import os
|
4 |
import time
|
5 |
+
import whisper
|
6 |
from gtts import gTTS
|
7 |
|
8 |
api_key = os.getenv('GROQ_API_KEY')
|
9 |
# Initialize Groq client
|
10 |
client = Groq(api_key=api_key)
|
11 |
|
12 |
+
# Load Whisper model
|
13 |
+
whisper_model = whisper.load_model("base") # You can use "tiny", "base", "small", "medium", or "large"
|
14 |
+
|
15 |
# Function to convert audio to text
|
16 |
def audio_to_text(audio_file):
|
17 |
+
# Use Whisper to transcribe audio
|
18 |
+
result = whisper_model.transcribe(audio_file)
|
19 |
+
return result['text']
|
|
|
|
|
20 |
|
21 |
# Function to convert text to audio
|
22 |
def text_to_audio(text):
|