MayamaTakeshi / sip-lab

A node module that helps to write SIP functional tests
3 stars 2 forks source link

Implement start_speech_recog #56

Closed MayamaTakeshi closed 3 months ago

MayamaTakeshi commented 6 months ago

This is to permit to test speech being generated in calls. This will permit to test mrcp servers and IVRs.

We can use this: https://github.com/cmusphinx/pocketsphinx

For actual code we can adapt from: https://github.com/Deepwalker/FreeSWITCH/blob/master/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c

MayamaTakeshi commented 3 months ago

It looks the mod_pocketsphinx is using an old version of pocketsphinx. Let's study the current pocketsphinx examples instead.

First I compiled pocketsphinx and a sample app:

git clone https://github.com/cmusphinx/pocketsphinx # got commit 7be89aae3e76568e02e4f3d41cf1adcb7654430c the latest at that time cmake . make cd examples gcc -o simple simple.c -I ../include/ -L ../ -lpocketsphinx -lm

Obs: i built pocketsphinx from source because the one installed by apt in ubuntu 22.04 is too old and the examples don't compile with it.

Then to build live_portaudio:

takeshi@takeshi-desktop:examples$ gcc -o live_portaudio live_portaudio.c -I ../include/ -L ../ -lpocketsphinx -lm -lportaudio

But in my machine it didn't work:

takeshi@takeshi-desktop:examples$ POCKETSPHINX_PATH=/home/takeshi/src/git/pocketsphinx/model/ ./live_portaudio ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card' ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card' ^Ctakeshi@takeshi-desktop:examples$

But anyway, it compiles and the code is simple. So we we will add pocketsphinx to build_deps.sh and code pocketsphinx_port.c based on live_portaudio.c. Let's first write a command-line app that reads data from a raw file and feeds it to ps_endpointer_process.

MayamaTakeshi commented 3 months ago

The freeswitch docs for mod_pocketsphinx seem to indicate it is OK to use it with sampling rate of 8000. So we might need to check to see if we are doing something wrong (or maybe good results require setting up a dictionary/grammar).