vosk-asterisk | Speech Recognition in Asterisk with Vosk Server | Speech library
kandi X-RAY | vosk-asterisk Summary
kandi X-RAY | vosk-asterisk Summary
Speech Recognition in Asterisk with Vosk Server
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of vosk-asterisk
vosk-asterisk Key Features
vosk-asterisk Examples and Code Snippets
Community Discussions
Trending Discussions on vosk-asterisk
QUESTION
In my live phone speech recognition project Python's asyncio
and websockets
modules are used basically to enable data exchange between client and server in asynchronous mode. The audio stream which to be recognized comes to the client from inside of a PBX channel (Asterisk PBX works for that) via a local wav
file that cumulates all data from answering call until hangup event. While conversation is going on, an async producer pushes chunks of call record (each of them no larger than 16 kB) to asyncio queue, so that a consumer coroutine can write data to buffer before sending to the recognition engine server (my pick is Vosk
instance with Kaldi
engine designed to connect using websocket interface). Once the buffer exceeds a specific capacity (for example it may be 288 kB), the data should be flushed to recognition by send
function and returned (as a transcript of the speech) by recv
. The real-time recognition does matter here, therefore I need to guarantee that socket operations like recv
will not halt both coroutines throughout websocket session (they should be able to keep queue-based data flow until the hangup event). Let's take a look at whole program, first of all there is a main
where an event loop gets instantiated as well as a couple of tasks:
ANSWER
Answered 2021-Mar-05 at 09:06If I understand the issue correctly, you probably want to replace await self.do_recognition()
with asyncio.create_task(self.do_recognition())
to make do_recognition
execute in the background. If you need to support Python 3.6 and earlier, you can use loop.create_task(...)
or asyncio.ensure_future(...)
, all of which in this case do the same thing.
When doing that you'll also need to extract the value of self._buffer
and pass it to do_recognition
as parameter, so that it can send the buffer contents independently of the new data that arrives.
Two notes unrelated to the question:
The code is accessing internal implementation attributes of queue, which should be avoided in production code because it can stop working at any point, even in a bugfix release of Python. Attributes that begin with
_
like_finished
and_unfinished_tasks
are not covered by backward compatibility guarantees and can be removed, renamed, or change meaning without notice.You can import
CancelledError
from the top-levelasyncio
package which exposes it publicly. You don't need to refer to the internalconcurrent.futures._base
module, which just happens to be where the class is defined by the implementation.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install vosk-asterisk
First build the modules
Edit modules.conf to load modules
Edit dialplan in extensions.conf:
Run Vosk server with the Docker
Dial extension and check the result
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page