File size: 651 Bytes
8d1b3ab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import wave
import io
from groq import Groq
class SpeechToText:
def __init__(self):
self.client=Groq()
async def trancribe_audio(self,audio_bytes:bytes):
wav_buffer=io.BytesIO(audio_bytes)
print("i am here")
try :
transcription = self.client.audio.transcriptions.create(
file=("audio.wav", wav_buffer),
model="whisper-large-v3-turbo"
)
print(f"the text is {transcription.text}")
return transcription.text
except Exception as e:
print(f"Error transcribing audio: {e}")
return None
|