alphacep / alphacep/vosk-api

question/feature_request(python): pause/resume

Đang mở
#162 6 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ả

### 1. Summary

I can't found, how I can pause and resume Vosk.

### 2. Argumentation

Me and my team uses Speech-To-Text technology for automatically (instead of manual) writing questions from intellectual games like “[**What? Where? When?**](https://en.wikipedia.org/wiki/What%3F_Where%3F_When%3F)”. How does this happen:

1. We start Speech-To-Text. The game host reads a question, which we write via Speech-To-Text.
1. When the host finishes reading the question, we stop Speech-To-Text and begin to discuss the question.

1. We use Speech-To-Text to peek into a question, if we forgot something in it. Using Speech-To-Text for our discussions interferes with this, creates additional difficulties.

1. When the host begin to read new question, we start Speech-To-Text again and so on.

We need pause/resume Speech-To-Text for this purpose. We don't know how we can do this in Vosk.

### 3. Examples in another apps

I can get the expected behavior if I use the [**Web Speech API**](https://developer.mozilla.org/ru/docs/Web/API/Web_Speech_API). I open [**Web Speech API demo page**](https://www.google.com/intl/en/chrome/demos/speech.html) in Chromium → I press to `Microphone` button, when I need start/restart or stop Speech-To-Text.

![Web Speech API](https://i.imgur.com/4cwLZOh.png)

### 4. Not helped

1. I can't found anything about pause/resume in [**Vosk documentation**](https://alphacephei.com/vosk/) and [**`vosk_api.h`**](https://github.com/alphacep/vosk-api/blob/master/src/vosk_api.h) file.
1. I tried Pause/Break, Ctrl+S, Ctrl+Z F10 keys as described in [**this**](https://superuser.com/q/1145483/572069) and [**this**](https://stackoverflow.com/q/8359317/5951529) answers — no effect.

### 5. Do not offer

> Close your console and run `python test_microphone.py` again

Vosk does not load instantly for use, users must wait. Frequent restart Vosk takes users time.

Using the Web Speech API (see section 3) users don't wait for anything.

### 6. Data

#### 6.1. Environment

1. Windows 10.0.18363 Pro N for Workstations 64-bit EN
1. Python 3.8.3
1. Vosk 0.3.7

#### 6.2. Script

Slightly modified [**`test_microphone.py`**](https://github.com/alphacep/vosk-api/blob/master/python/example/test_microphone.py):

```python
"""Test Vosk microphone."""
import json
import os
import sys

import pyaudio

from vosk import KaldiRecognizer
from vosk import Model

if not os.path.exists("model"):
print("Please download the model and unpack as 'model' in the current folder.")
sys.exit()

MODEL = Model("model")
REC = KaldiRecognizer(MODEL, 16000)

P = pyaudio.PyAudio()
STREAM = P.open(
format=pyaudio.paInt16,
channels=1,
rate=16000,
input=True,
frames_per_buffer=8000)
STREAM.start_stream()

while True:
DATA = STREAM.read(14000)
if len(DATA) == 0:
pass
if REC.AcceptWaveform(DATA):
KIRA_RESULT = REC.Result()
KIRA_PARSED_JSON = json.loads(KIRA_RESULT)
print(KIRA_PARSED_JSON['text'])

```

Thanks.

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.