alphacep / alphacep/vosk-api

test_gradio.py with vosk not working

Đang mở
#1,214 9 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Jupyter Notebook
Star
15.1k
Fork
1.8k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.