Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d497c3a0a5 | |||
| f37ee638a4 | |||
| e0b29bb17f |
@@ -10,7 +10,7 @@ buildscript {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
version = '0.3.50'
|
||||
version = '0.3.47'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
||||
@@ -118,7 +118,7 @@ CXX=$CXX AR=$AR RANLIB=$RANLIB CXXFLAGS="$ARCHFLAGS -O3 -DFST_NO_DYNAMIC_LINKING
|
||||
--fst-root=${WORKDIR}/local --fst-version=${OPENFST_VERSION}
|
||||
make -j 8 depend
|
||||
cd $WORKDIR/kaldi/src
|
||||
make -j 8 online2 rnnlm
|
||||
make -j 8 online2 lm rnnlm
|
||||
|
||||
# Vosk-api
|
||||
cd $WORKDIR
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Vosk" Version="0.3.50" />
|
||||
<PackageReference Include="Vosk" Version="0.3.45" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<package>
|
||||
<metadata>
|
||||
<id>Vosk</id>
|
||||
<version>0.3.50</version>
|
||||
<version>0.3.45</version>
|
||||
<authors>Alpha Cephei Inc</authors>
|
||||
<owners>Alpha Cephei Inc</owners>
|
||||
<license type="expression">Apache-2.0</license>
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
package vosk
|
||||
|
||||
// #cgo CPPFLAGS: -I ${SRCDIR}/../src
|
||||
// #cgo !windows LDFLAGS: -L ${SRCDIR}/../src -lvosk -ldl -lpthread
|
||||
// #cgo windows LDFLAGS: -L ${SRCDIR}/../src -lvosk -lpthread
|
||||
// #cgo LDFLAGS: -L ${SRCDIR}/../src -lvosk -ldl -lpthread
|
||||
// #include <stdlib.h>
|
||||
// #include <vosk_api.h>
|
||||
import "C"
|
||||
|
||||
@@ -11,5 +11,5 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation group: 'com.alphacephei', name: 'vosk', version: '0.3.50'
|
||||
implementation group: 'com.alphacephei', name: 'vosk', version: '0.3.45'
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ repositories {
|
||||
|
||||
archivesBaseName = 'vosk'
|
||||
group = 'com.alphacephei'
|
||||
version = '0.3.50'
|
||||
version = '0.3.45'
|
||||
|
||||
mavenPublish {
|
||||
group = 'com.alphacephei'
|
||||
|
||||
@@ -26,7 +26,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.alphacephei"
|
||||
version = "0.3.50"
|
||||
version = "0.4.0-alpha0"
|
||||
|
||||
repositories {
|
||||
google()
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vosk",
|
||||
"version": "0.3.50",
|
||||
"version": "0.3.45",
|
||||
"description": "Node binding for continuous offline voice recoginition with Vosk library.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -41,7 +41,7 @@ if wf.getnchannels() != 1 or wf.getsampwidth() != 2 or wf.getcomptype() != "NONE
|
||||
print("Audio file must be WAV format mono PCM.")
|
||||
sys.exit(1)
|
||||
|
||||
rec.SetEndpointerDelays(0.5, 0.3, 10.0)
|
||||
rec.SetEndpointerDelays(300, 500, 2000)
|
||||
|
||||
while True:
|
||||
data = wf.readframes(4000)
|
||||
|
||||
@@ -1,39 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import gradio as gr
|
||||
|
||||
from vosk import KaldiRecognizer, Model
|
||||
|
||||
model = Model(lang="en-us")
|
||||
|
||||
def transcribe(stream, new_chunk):
|
||||
|
||||
sample_rate, audio_data = new_chunk
|
||||
audio_data = audio_data.tobytes()
|
||||
|
||||
if stream is None:
|
||||
rec = KaldiRecognizer(model, sample_rate)
|
||||
result = []
|
||||
else:
|
||||
rec, result = stream
|
||||
|
||||
if rec.AcceptWaveform(audio_data):
|
||||
text_result = json.loads(rec.Result())["text"]
|
||||
if text_result != "":
|
||||
result.append(text_result)
|
||||
partial_result = ""
|
||||
else:
|
||||
partial_result = json.loads(rec.PartialResult())["partial"] + " "
|
||||
|
||||
return (rec, result), "\n".join(result) + "\n" + partial_result
|
||||
|
||||
gr.Interface(
|
||||
fn=transcribe,
|
||||
inputs=[
|
||||
"state", gr.Audio(sources=["microphone"], type="numpy", streaming=True),
|
||||
],
|
||||
outputs=[
|
||||
"state", "text",
|
||||
],
|
||||
live=True).launch(share=True)
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import gradio as gr
|
||||
|
||||
from vosk import KaldiRecognizer, Model
|
||||
|
||||
model = Model(lang="en-us")
|
||||
|
||||
def transcribe(data, state):
|
||||
sample_rate, audio_data = data
|
||||
audio_data = (audio_data >> 16).astype("int16").tobytes()
|
||||
|
||||
if state is None:
|
||||
rec = KaldiRecognizer(model, sample_rate)
|
||||
result = []
|
||||
else:
|
||||
rec, result = state
|
||||
|
||||
if rec.AcceptWaveform(audio_data):
|
||||
text_result = json.loads(rec.Result())["text"]
|
||||
if text_result != "":
|
||||
result.append(text_result)
|
||||
partial_result = ""
|
||||
else:
|
||||
partial_result = json.loads(rec.PartialResult())["partial"] + " "
|
||||
|
||||
return "\n".join(result) + "\n" + partial_result, (rec, result)
|
||||
|
||||
gr.Interface(
|
||||
fn=transcribe,
|
||||
inputs=[
|
||||
gr.Audio(source="microphone", type="numpy", streaming=True),
|
||||
"state"
|
||||
],
|
||||
outputs=[
|
||||
"textbox",
|
||||
"state"
|
||||
],
|
||||
live=True).launch(share=True)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import wave
|
||||
import sys
|
||||
|
||||
from vosk import Processor
|
||||
|
||||
proc = Processor("ru_itn_tagger.fst", "ru_itn_verbalizer.fst")
|
||||
print (proc.process("у нас десять яблок"))
|
||||
print (proc.process("у нас десять яблок и десять миллилитров воды точка"))
|
||||
print (proc.process("мы пришли в восемь часов пять минут"))
|
||||
+1
-1
@@ -45,7 +45,7 @@ with open("README.md", "rb") as fh:
|
||||
|
||||
setuptools.setup(
|
||||
name="vosk",
|
||||
version="0.3.50",
|
||||
version="0.3.46",
|
||||
author="Alpha Cephei Inc",
|
||||
author_email="contact@alphacephei.com",
|
||||
description="Offline open source speech recognition API based on Kaldi and Vosk",
|
||||
|
||||
+11
-19
@@ -144,9 +144,15 @@ class SpkModel:
|
||||
|
||||
class EndpointerMode(enum.Enum):
|
||||
DEFAULT = 0
|
||||
SHORT = 1
|
||||
LONG = 2
|
||||
VERY_LONG = 3
|
||||
SINGLE_WORD = 1
|
||||
VERY_SHORT = 2
|
||||
SHORT = 3
|
||||
STANDARD = 4
|
||||
STANDARD_5 = 5
|
||||
STANDARD_180 = 6
|
||||
LONG = 7
|
||||
VERY_LONG = 8
|
||||
VERY_LONG_180 = 9
|
||||
|
||||
class KaldiRecognizer:
|
||||
|
||||
@@ -183,8 +189,8 @@ class KaldiRecognizer:
|
||||
def SetEndpointerMode(self, mode):
|
||||
_c.vosk_recognizer_set_endpointer_mode(self._handle, mode.value)
|
||||
|
||||
def SetEndpointerDelays(self, t_start_max, t_end, t_max):
|
||||
_c.vosk_recognizer_set_endpointer_delays(self._handle, t_start_max, t_end, t_max)
|
||||
def SetEndpointerDelays(self, sct, nit, t):
|
||||
_c.vosk_recognizer_set_endpointer_delays(self._handle, sct, nit, t)
|
||||
|
||||
def SetSpkModel(self, spk_model):
|
||||
_c.vosk_recognizer_set_spk_model(self._handle, spk_model._handle)
|
||||
@@ -287,17 +293,3 @@ class BatchRecognizer:
|
||||
|
||||
def GetPendingChunks(self):
|
||||
return _c.vosk_batch_recognizer_get_pending_chunks(self._handle)
|
||||
|
||||
class Processor:
|
||||
|
||||
def __init__(self, *args):
|
||||
self._handle = _c.vosk_text_processor_new(args[0].encode('utf-8'), args[1].encode('utf-8'))
|
||||
|
||||
if self._handle == _ffi.NULL:
|
||||
raise Exception("Failed to create processor")
|
||||
|
||||
def __del__(self):
|
||||
_c.vosk_text_processor_free(self._handle)
|
||||
|
||||
def process(self, text):
|
||||
return _ffi.string(_c.vosk_text_processor_itn(self._handle, text.encode('utf-8'))).decode('utf-8')
|
||||
|
||||
@@ -15,8 +15,8 @@ parser.add_argument(
|
||||
"--model", "-m", type=str,
|
||||
help="model path")
|
||||
parser.add_argument(
|
||||
"--server", "-s", type=str,
|
||||
help="use server for recognition. For example ws://localhost:2700")
|
||||
"--server", "-s", const="ws://localhost:2700", action="store_const",
|
||||
help="use server for recognition")
|
||||
parser.add_argument(
|
||||
"--list-models", default=False, action="store_true",
|
||||
help="list available models")
|
||||
|
||||
@@ -99,7 +99,7 @@ class Transcriber:
|
||||
monologues = {"schemaVersion":"2.0", "monologues":[], "text":[]}
|
||||
for part in result:
|
||||
if part["text"] != "":
|
||||
monologues["text"] += [part["text"]]
|
||||
monologues["text"] += part["text"]
|
||||
for _, res in enumerate(result):
|
||||
if not "result" in res:
|
||||
continue
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "vosk"
|
||||
s.version = "0.3.50"
|
||||
s.version = "0.3.45"
|
||||
s.summary = "Offline speech recognition API"
|
||||
s.description = "Vosk is an offline open source speech recognition toolkit. It enables speech recognition for 20+ languages and dialects - English, Indian English, German, French, Spanish, Portuguese, Chinese, Russian, Turkish, Vietnamese, Italian, Dutch, Catalan, Arabic, Greek, Farsi, Filipino, Ukrainian, Kazakh, Swedish, Japanese, Esperanto, Hindi, Czech, Polish. More to come."
|
||||
s.authors = ["Alpha Cephei Inc"]
|
||||
|
||||
+4
-5
@@ -23,18 +23,17 @@ VOSK_SOURCES= \
|
||||
language_model.cc \
|
||||
model.cc \
|
||||
spk_model.cc \
|
||||
vosk_api.cc \
|
||||
postprocessor.cc
|
||||
vosk_api.cc
|
||||
|
||||
VOSK_HEADERS= \
|
||||
recognizer.h \
|
||||
language_model.h \
|
||||
model.h \
|
||||
spk_model.h \
|
||||
vosk_api.h \
|
||||
postprocessor.h
|
||||
vosk_api.h
|
||||
|
||||
CFLAGS=-g -O3 -std=c++17 -Wno-deprecated-declarations -fPIC -DFST_NO_DYNAMIC_LINKING -I. -I$(KALDI_ROOT)/src -I$(OPENFST_ROOT)/include $(EXTRA_CFLAGS)
|
||||
CFLAGS=-g -O3 -std=c++17 -Wno-deprecated-declarations -fPIC -DFST_NO_DYNAMIC_LINKING \
|
||||
-I. -I$(KALDI_ROOT)/src -I$(OPENFST_ROOT)/include $(EXTRA_CFLAGS)
|
||||
|
||||
LDFLAGS=
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
// Copyright (c) 2022 Zhendong Peng (pzd17@tsinghua.org.cn)
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "postprocessor.h"
|
||||
|
||||
using fst::TokenType;
|
||||
|
||||
Processor::Processor(const std::string& tagger_path,
|
||||
const std::string& verbalizer_path) {
|
||||
tagger_.reset(StdVectorFst::Read(tagger_path));
|
||||
verbalizer_.reset(StdVectorFst::Read(verbalizer_path));
|
||||
compiler_ = std::make_shared<StringCompiler<StdArc>>(TokenType::BYTE);
|
||||
printer_ = std::make_shared<StringPrinter<StdArc>>(TokenType::BYTE);
|
||||
}
|
||||
|
||||
std::string Processor::ShortestPath(const StdVectorFst& lattice) {
|
||||
StdVectorFst shortest_path;
|
||||
fst::ShortestPath(lattice, &shortest_path, 1, true);
|
||||
|
||||
std::string output;
|
||||
printer_->operator()(shortest_path, &output);
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string Processor::Compose(const std::string& input,
|
||||
const StdVectorFst* fst) {
|
||||
StdVectorFst input_fst;
|
||||
compiler_->operator()(input, &input_fst);
|
||||
|
||||
StdVectorFst lattice;
|
||||
fst::Compose(input_fst, *fst, &lattice);
|
||||
return ShortestPath(lattice);
|
||||
}
|
||||
|
||||
std::string Processor::Tag(const std::string& input) {
|
||||
if (input.empty()) {
|
||||
return "";
|
||||
}
|
||||
return Compose(input, tagger_.get());
|
||||
}
|
||||
|
||||
std::string Processor::Verbalize(const std::string& input) {
|
||||
if (input.empty()) {
|
||||
return "";
|
||||
}
|
||||
std::string output = Compose(input, verbalizer_.get());
|
||||
output.erase(std::remove(output.begin(), output.end(), '\0'), output.end());
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string Processor::Normalize(const std::string& input) {
|
||||
return Verbalize(Tag(input));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
// Copyright (c) 2022 Zhendong Peng (pzd17@tsinghua.org.cn)
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef PROCESSOR_WETEXT_PROCESSOR_H_
|
||||
#define PROCESSOR_WETEXT_PROCESSOR_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "fst/fstlib.h"
|
||||
|
||||
using fst::StdArc;
|
||||
using fst::StdVectorFst;
|
||||
using fst::StringCompiler;
|
||||
using fst::StringPrinter;
|
||||
|
||||
class Processor {
|
||||
public:
|
||||
Processor(const std::string& tagger_path, const std::string& verbalizer_path);
|
||||
std::string Tag(const std::string& input);
|
||||
std::string Verbalize(const std::string& input);
|
||||
std::string Normalize(const std::string& input);
|
||||
|
||||
private:
|
||||
std::string ShortestPath(const StdVectorFst& lattice);
|
||||
std::string Compose(const std::string& input, const StdVectorFst* fst);
|
||||
|
||||
std::shared_ptr<StdVectorFst> tagger_ = nullptr;
|
||||
std::shared_ptr<StdVectorFst> verbalizer_ = nullptr;
|
||||
std::shared_ptr<StringCompiler<StdArc>> compiler_ = nullptr;
|
||||
std::shared_ptr<StringPrinter<StdArc>> printer_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // PROCESSOR_WETEXT_PROCESSOR_H_
|
||||
+92
-18
@@ -222,36 +222,110 @@ void Recognizer::SetNLSML(bool nlsml)
|
||||
|
||||
void Recognizer::SetEndpointerMode(int mode)
|
||||
{
|
||||
float rule1, rule2, rule3, rule4, rule5;
|
||||
if (mode == 0) {
|
||||
endpoint_config_ = model_->endpoint_config_;
|
||||
return;
|
||||
}
|
||||
|
||||
float scale = 1.0;
|
||||
switch(mode) {
|
||||
case 1:
|
||||
scale = 0.75;
|
||||
case 1: // SINGLE_WORD
|
||||
rule2 = 0.1;
|
||||
rule3 = 0.15;
|
||||
rule4 = 0.2;
|
||||
rule1 = 4.0;
|
||||
rule5 = 7.0;
|
||||
break;
|
||||
case 2:
|
||||
scale = 1.50;
|
||||
case 2: // VERY_SHORT
|
||||
rule2 = 0.3;
|
||||
rule3 = 0.3;
|
||||
rule4 = 0.6;
|
||||
rule1 = 3.0;
|
||||
rule5 = 5.0;
|
||||
break;
|
||||
case 3:
|
||||
scale = 4.0;
|
||||
case 3: // SHORT
|
||||
rule2 = 0.3;
|
||||
rule3 = 0.4;
|
||||
rule4 = 0.6;
|
||||
rule1 = 3.0;
|
||||
rule5 = 5.0;
|
||||
break;
|
||||
case 4: // STANDARD
|
||||
rule2 = 0.8;
|
||||
rule3 = 0.9;
|
||||
rule4 = 1.0;
|
||||
rule1 = 3.0;
|
||||
rule5 = 7.0;
|
||||
break;
|
||||
case 5: // STANDARD_5
|
||||
rule2 = 0.8;
|
||||
rule3 = 0.9;
|
||||
rule4 = 1.5;
|
||||
rule1 = 5.0;
|
||||
rule5 = 7.0;
|
||||
break;
|
||||
case 6: // STANDARD_180
|
||||
rule2 = 0.8;
|
||||
rule3 = 0.9;
|
||||
rule4 = 1.5;
|
||||
rule1 = 3.0;
|
||||
rule5 = 180.0;
|
||||
break;
|
||||
case 7: // LONG
|
||||
rule2 = 1.0;
|
||||
rule3 = 1.2;
|
||||
rule4 = 2.0;
|
||||
rule1 = 4.0;
|
||||
rule5 = 10.0;
|
||||
break;
|
||||
case 8: // VERY_LONG
|
||||
rule2 = 2.0;
|
||||
rule3 = 2.5;
|
||||
rule4 = 3.0;
|
||||
rule1 = 4.0;
|
||||
rule5 = 15.0;
|
||||
break;
|
||||
case 9: // VERY_LONG_180
|
||||
rule2 = 2.0;
|
||||
rule3 = 2.5;
|
||||
rule4 = 3.0;
|
||||
rule1 = 4.0;
|
||||
rule5 = 180.0;
|
||||
break;
|
||||
default: // STANDARD
|
||||
rule2 = 0.8;
|
||||
rule3 = 0.9;
|
||||
rule4 = 1.0;
|
||||
rule1 = 5.0;
|
||||
rule5 = 7.0;
|
||||
break;
|
||||
}
|
||||
KALDI_LOG << "Updating endpointer scale " << scale;
|
||||
KALDI_LOG << "Updating endpointer timeouts to " << rule1 << "," << rule2 << "," << rule3 << "," << rule4 << "," << rule5;
|
||||
endpoint_config_ = model_->endpoint_config_;
|
||||
endpoint_config_.rule2.min_trailing_silence *= scale;
|
||||
endpoint_config_.rule3.min_trailing_silence *= scale;
|
||||
endpoint_config_.rule4.min_trailing_silence *= scale;
|
||||
endpoint_config_.rule1.min_trailing_silence = rule1;
|
||||
endpoint_config_.rule2.min_trailing_silence = rule2;
|
||||
endpoint_config_.rule3.min_trailing_silence = rule3;
|
||||
endpoint_config_.rule4.min_trailing_silence = rule4;
|
||||
endpoint_config_.rule5.min_utterance_length = rule5;
|
||||
}
|
||||
|
||||
void Recognizer::SetEndpointerDelays(float t_start_max, float t_end, float t_max)
|
||||
void Recognizer::SetEndpointerDelays(int sct, int nit, int t)
|
||||
{
|
||||
float rule1, rule2, rule3, rule4, rule5;
|
||||
|
||||
rule1 = t_start_max;
|
||||
rule2 = t_end;
|
||||
rule3 = t_end + 0.5;
|
||||
rule4 = t_end + 1.0;
|
||||
rule5 = t_max;
|
||||
rule2 = sct / 1000.0;
|
||||
if (sct < 500) {
|
||||
rule3 = sct / 1000.0 * 1.5;
|
||||
rule4 = sct / 1000.0 * 2;
|
||||
} else {
|
||||
rule3 = sct / 1000.0 + 0.5;
|
||||
rule4 = sct / 1000.0 + 1.0;
|
||||
}
|
||||
rule1 = nit / 1000.0;
|
||||
rule5 = t / 1000.0;
|
||||
|
||||
KALDI_LOG << "Updating endpointer delays " << rule1 << "," << rule2 << "," << rule3 << "," << rule4 << "," << rule5;
|
||||
KALDI_LOG << "Updating endpointer timeouts to " << rule1 << "," << rule2 << "," << rule3 << "," << rule4 << "," << rule5;
|
||||
endpoint_config_ = model_->endpoint_config_;
|
||||
endpoint_config_.rule1.min_trailing_silence = rule1;
|
||||
endpoint_config_.rule2.min_trailing_silence = rule2;
|
||||
@@ -275,7 +349,7 @@ void Recognizer::SetSpkModel(SpkModel *spk_model)
|
||||
void Recognizer::SetGrm(char const *grammar)
|
||||
{
|
||||
if (state_ == RECOGNIZER_RUNNING) {
|
||||
KALDI_ERR << "Can't add grammar to already running recognizer";
|
||||
KALDI_ERR << "Can't add speaker model to already running recognizer";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ class Recognizer {
|
||||
void SetPartialWords(bool partial_words);
|
||||
void SetNLSML(bool nlsml);
|
||||
void SetEndpointerMode(int mode);
|
||||
void SetEndpointerDelays(float t_start_max, float t_end, float t_max);
|
||||
void SetEndpointerDelays(int sct, int nit, int t);
|
||||
bool AcceptWaveform(const char *data, int len);
|
||||
bool AcceptWaveform(const short *sdata, int len);
|
||||
bool AcceptWaveform(const float *fdata, int len);
|
||||
|
||||
+2
-28
@@ -17,7 +17,6 @@
|
||||
#include "recognizer.h"
|
||||
#include "model.h"
|
||||
#include "spk_model.h"
|
||||
#include "postprocessor.h"
|
||||
|
||||
#if HAVE_CUDA
|
||||
#include "cudamatrix/cu-device.h"
|
||||
@@ -138,12 +137,12 @@ void vosk_recognizer_set_endpointer_mode(VoskRecognizer *recognizer, VoskEndpoin
|
||||
((Recognizer *)recognizer)->SetEndpointerMode(mode);
|
||||
}
|
||||
|
||||
void vosk_recognizer_set_endpointer_delays(VoskRecognizer *recognizer, float t_start_max, float t_end, float t_max)
|
||||
void vosk_recognizer_set_endpointer_delays(VoskRecognizer *recognizer, int sct, int nit, int t)
|
||||
{
|
||||
if (recognizer == nullptr) {
|
||||
return;
|
||||
}
|
||||
((Recognizer *)recognizer)->SetEndpointerDelays(t_start_max, t_end, t_max);
|
||||
((Recognizer *)recognizer)->SetEndpointerDelays(sct, nit, t);
|
||||
}
|
||||
|
||||
int vosk_recognizer_accept_waveform(VoskRecognizer *recognizer, const char *data, int length)
|
||||
@@ -305,28 +304,3 @@ int vosk_batch_recognizer_get_pending_chunks(VoskBatchRecognizer *recognizer)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
VoskTextProcessor *vosk_text_processor_new(const char *tagger, const char *verbalizer)
|
||||
{
|
||||
try {
|
||||
return (VoskTextProcessor *)new Processor(tagger, verbalizer);
|
||||
} catch (...) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void vosk_text_processor_free(VoskTextProcessor *processor)
|
||||
{
|
||||
delete ((Processor *)processor);
|
||||
}
|
||||
|
||||
char *vosk_text_processor_itn(VoskTextProcessor *processor, const char *input)
|
||||
{
|
||||
Processor *wprocessor = (Processor *)processor;
|
||||
std::string sinput(input);
|
||||
|
||||
std::string tagged_text = wprocessor->Tag(sinput);
|
||||
std::string normalized_text = wprocessor->Verbalize(tagged_text);
|
||||
|
||||
return strdup(normalized_text.c_str());
|
||||
}
|
||||
|
||||
+16
-20
@@ -39,8 +39,6 @@ typedef struct VoskSpkModel VoskSpkModel;
|
||||
* speaker information and so on */
|
||||
typedef struct VoskRecognizer VoskRecognizer;
|
||||
|
||||
/** Inverse text normalization */
|
||||
typedef struct VoskTextProcessor VoskTextProcessor;
|
||||
|
||||
/**
|
||||
* Batch model object
|
||||
@@ -219,11 +217,17 @@ void vosk_recognizer_set_partial_words(VoskRecognizer *recognizer, int partial_w
|
||||
*/
|
||||
void vosk_recognizer_set_nlsml(VoskRecognizer *recognizer, int nlsml);
|
||||
|
||||
typedef enum VoskEpMode {
|
||||
VOSK_EP_ANSWER_DEFAULT = 0,
|
||||
VOSK_EP_ANSWER_SHORT = 1,
|
||||
VOSK_EP_ANSWER_LONG = 2,
|
||||
VOSK_EP_ANSWER_VERY_LONG = 3,
|
||||
typedef enum VoskEndpointerMode {
|
||||
VOSK_EP_DEFAULT = 0,
|
||||
VOSK_EP_SINGLE_WORD = 1,
|
||||
VOSK_EP_VERY_SHORT = 2,
|
||||
VOSK_EP_SHORT = 3,
|
||||
VOSK_EP_STANDARD = 4,
|
||||
VOSK_EP_STANDARD_5 = 5,
|
||||
VOSK_EP_STANDARD_180 = 6,
|
||||
VOSK_EP_LONG = 7,
|
||||
VOSK_EP_VERY_LONG = 8,
|
||||
VOSK_EP_VERY_LONG_180 = 9
|
||||
} VoskEndpointerMode;
|
||||
|
||||
/**
|
||||
@@ -236,11 +240,12 @@ void vosk_recognizer_set_endpointer_mode(VoskRecognizer *recognizer, VoskEndpoi
|
||||
/**
|
||||
* Set endpointer delays
|
||||
*
|
||||
* @param t_start_max timeout for stopping recognition in case of initial silence (usually around 5.0)
|
||||
* @param t_end timeout for stopping recognition in milliseconds after we recognized something (usually around 0.5 - 1.0)
|
||||
* @param t_max timeout for forcing utterance end in milliseconds (usually around 20-30)
|
||||
* @param sct speech complete timeout
|
||||
* @param sint speech incomplete timeout
|
||||
* @param nit no input timeout
|
||||
* @param t recognition timeout
|
||||
**/
|
||||
void vosk_recognizer_set_endpointer_delays(VoskRecognizer *recognizer, float t_start_max, float t_end, float t_max);
|
||||
void vosk_recognizer_set_endpointer_delays(VoskRecognizer *recognizer, int sct, int nit, int t);
|
||||
|
||||
/** Accept voice data
|
||||
*
|
||||
@@ -378,15 +383,6 @@ void vosk_batch_recognizer_pop(VoskBatchRecognizer *recognizer);
|
||||
/** Get amount of pending chunks for more intelligent waiting */
|
||||
int vosk_batch_recognizer_get_pending_chunks(VoskBatchRecognizer *recognizer);
|
||||
|
||||
/** Create text processor */
|
||||
VoskTextProcessor *vosk_text_processor_new(const char *tagger, const char *verbalizer);
|
||||
|
||||
/** Release text processor */
|
||||
void vosk_text_processor_free(VoskTextProcessor *processor);
|
||||
|
||||
/** Convert string */
|
||||
char *vosk_text_processor_itn(VoskTextProcessor *processor, const char *input);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -45,5 +45,5 @@ RUN cd /opt \
|
||||
&& sed -i "s:TARGET_ARCH=\"\`uname -m\`\":TARGET_ARCH=$(echo $CROSS_TRIPLE|cut -d - -f 1):g" configure \
|
||||
&& sed -i "s: -O1 : -O3 :g" makefiles/linux_openblas_arm.mk \
|
||||
&& ./configure --mathlib=OPENBLAS_CLAPACK --shared --use-cuda=no \
|
||||
&& make -j 10 online2 rnnlm \
|
||||
&& make -j 10 online2 lm rnnlm \
|
||||
&& find /opt/kaldi -name "*.o" -exec rm {} \;
|
||||
|
||||
@@ -35,5 +35,5 @@ RUN cd /opt \
|
||||
&& sed -i "s:TARGET_ARCH=\"\`uname -m\`\":TARGET_ARCH=$(echo $CROSS_TRIPLE|cut -d - -f 1):g" configure \
|
||||
&& sed -i "s: -O1 : -O3 :g" makefiles/linux_openblas_arm.mk \
|
||||
&& ./configure --mathlib=OPENBLAS_CLAPACK --shared --use-cuda=no \
|
||||
&& make -j 10 online2 rnnlm \
|
||||
&& make -j 10 online2 lm rnnlm \
|
||||
&& find /opt/kaldi -name "*.o" -exec rm {} \;
|
||||
|
||||
@@ -30,5 +30,5 @@ RUN cd /opt \
|
||||
&& ./configure --mathlib=OPENBLAS_CLAPACK --shared --use-cuda=no \
|
||||
&& sed -i 's:-msse -msse2:-msse -msse2:g' kaldi.mk \
|
||||
&& sed -i 's: -O1 : -O3 :g' kaldi.mk \
|
||||
&& make -j $(nproc) online2 rnnlm \
|
||||
&& make -j $(nproc) online2 lm rnnlm \
|
||||
&& find /opt/kaldi -name "*.o" -exec rm {} \;
|
||||
|
||||
@@ -27,5 +27,5 @@ RUN cd /opt \
|
||||
&& ./configure --mathlib=MKL --shared --use-cuda=no \
|
||||
&& sed -i 's:-msse -msse2:-msse -msse2 -mavx -mavx2:g' kaldi.mk \
|
||||
&& sed -i 's: -O1 : -O3 :g' kaldi.mk \
|
||||
&& make -j $(nproc) online2 rnnlm \
|
||||
&& make -j $(nproc) online2 lm rnnlm \
|
||||
&& find /opt/kaldi -name "*.o" -exec rm {} \;
|
||||
|
||||
@@ -62,4 +62,4 @@ RUN cd /opt/kaldi \
|
||||
--host=x86_64-w64-mingw32 --openblas-clapack-root=/opt/kaldi/local \
|
||||
--fst-root=/opt/kaldi/local --fst-version=1.8.0 \
|
||||
&& make depend -j \
|
||||
&& make -j $(nproc) online2 rnnlm
|
||||
&& make -j $(nproc) online2 lm rnnlm
|
||||
|
||||
@@ -61,4 +61,4 @@ RUN cd /opt/kaldi \
|
||||
--host=i686-w64-mingw32 --openblas-clapack-root=/opt/kaldi/local \
|
||||
--fst-root=/opt/kaldi/local --fst-version=1.8.0 \
|
||||
&& make depend -j \
|
||||
&& make -j $(nproc) online2 rnnlm
|
||||
&& make -j $(nproc) online2 lm rnnlm
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vosk-js",
|
||||
"version": "0.3.50",
|
||||
"version": "0.3.45",
|
||||
"description": "Node binding for continuous voice recoginition through vosk-api.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user