forked from alphacep/vosk-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from vosk import Model, KaldiRecognizer, SetLogLevel | ||
import sys | ||
import os | ||
import wave | ||
|
||
SetLogLevel(0) | ||
|
||
if not os.path.exists("model"): | ||
print ("Please download the model from https://alphacephei.com/vosk/models and unpack as 'model' in the current folder.") | ||
exit (1) | ||
|
||
wf = wave.open(sys.argv[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()) | ||
rec.SetMaxAlternatives(10) | ||
rec.SetNLSML(True) | ||
|
||
while True: | ||
data = wf.readframes(4000) | ||
if len(data) == 0: | ||
break | ||
if rec.AcceptWaveform(data): | ||
print(rec.Result()) | ||
|
||
print(rec.FinalResult()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters