alphacep / alphacep/vosk-api

test_gradio.py with vosk not working

Aperta
#1,214 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Jupyter Notebook
Stelle
15.1k
Fork
1.8k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.