Generation

generate functionSun, 04 Dec 2022

Offline speech recognition vosk

def offline_speech_to_text(filename): config = recognize.Model(model='model') recognizer = recognize.StreamingRecognizer(config=config, sample_rate=16000) wf = wave.open(filename) while True: buf = wf.readframes(1024) if buf: recognizer.accept_audio(buf) else: break hypotheses = recognizer.result() return hypotheses[0].lower() if hypotheses else ""

Want to kickstart your project?Use the new AI Studio to create your code