configuration pour transcrire des fichiers audio wav avec Vosk
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
770 B

#!/usr/bin/env python3
from vosk import Model, KaldiRecognizer, SetLogLevel
import sys
import os
import wave
if not os.path.exists("model"):
print ("Please download the model from and unpack as 'model' in the current folder.")
exit (1)
wf =[1], "rb")
if wf.getnchannels() != 1 or wf.getsampwidth() != 2 or wf.getcomptype() != "NONE":
print ("Audio file must be WAV format mono PCM.")
exit (1)
model = Model("model")
rec = KaldiRecognizer(model, wf.getframerate())
while True:
data = wf.readframes(4000)
if len(data) == 0:
if rec.AcceptWaveform(data):
# print(rec.PartialResult())