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 | |