alphacep / alphacep/vosk-api

test_gradio.py with vosk not working

オープン
#1,214 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Jupyter Notebook
スター
15.1k
フォーク
1.8k
PR マージ指標
30日以内にマージされた PR はありません

説明

Hello,
I want to present vosk on the gradio service using the Turkish model, but I could not achieve this.

I can run the code but it doesn't write anything on the gradio screen.

When I examine the code a bit, I can actually get the sound in bytes, but rec.Result returns empty.
*******************************************************
('\n ', (, []))
***********************************************************************
i am making the sample code with you can you help please;

```
import json
import gradio as gr

from vosk import KaldiRecognizer, Model

model = Model(r"C:\Users\Administrator\PycharmProjects\vosk\model\vosk-model-small-tr-0.3\vosk-model-small-tr-0.3")

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。