CMU Sphinx adapting the default acoustic model with Cygwin - cygwin

I followed the adaptation guide in this link to adapt the default acoustic model. But when I ran the following code segment,
for i in seq 1 20; do
fn=printf arctic_%04d $i;
read sent; echo $sent;
rec -r 16000 -e signed-integer -b 16 -c 1 $fn.wav 2>/dev/null;
done < arctic20.txt
in Cygwin terminal, it prints all the 20 sentences to the screen in a one go. So I can not record the sentences.But according to the tutorial it should print each sentence one by one to the screen. I followed all the instructions in the tutorial so far. What could be the problem? please help!

Related

why does the numbers be reduced 256 when set memory.limit_in_bytes

the command snippet is as follow:
sudo mkdir /sys/fs/cgroup/memory/demo
cat /sys/fs/cgroup/memory/demo/memory.limit_in_bytes
# output: 9223372036854771712
echo 100000000 > /sys/fs/cgroup/memory/demo/memory.limit_in_bytes
cat /sys/fs/cgroup/memory/demo/memory.limit_in_bytes
# output: 99999744
My Question is:
Why the 100000000 be changed to 99999744? I have noticed the difference value is 256, so I think something happened, but I don't know that. I can't find anything about this on the Internet or stackoverflow.

Gnu parallel getting stuck, not giving output

Parallel seems to be installed properly as I am able to run basic parallel check commands.
# parallel --version
GNU parallel 20161222
Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014,2015,2016
Ole Tange and Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
GNU parallel comes with no warranty.
Web site: http://www.gnu.org/software/parallel
When using programs that use GNU Parallel to process data for publication
please cite as described in 'parallel --citation'.
But when I'm trying to execute a query on remote servers it doesn't give any output also doesn't returns the prompt.. eg :-
parallel ssh {} hostname :::: hosts
Academic tradition requires you to cite works you base your article on.
When using programs that use GNU Parallel to process data for publication
please cite:
O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
;login: The USENIX Magazine, February 2011:42-47.
This helps funding further development; AND IT WON'T COST YOU A CENT.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice: run 'parallel --citation'.
in above eg , hosts file contains a list of remote server IP's
Even a simple parallel echo ::: A B C command doens's gives output..
I tried running with /usr/bin/parallel but issue remains..
when I ran the command using bash -x I get the following error :-
bash -x parallel ssh {} hostname :::: hosts
+ use IPC::Open3
/usr/bin/parallel: line 22: use: command not found
/usr/bin/parallel: parallel: line 24: syntax error near unexpected token `('
/usr/bin/parallel: parallel: line 24: `use POSIX qw(:sys_wait_h setsid ceil :errno_h);'
I've checked the file /usr/bin/parallel seems fine to me.
Not able to find solution for this. Any help is really appreciated.
Thanks.
UPDATE_1 :-
root#sg-server:[~]:# parallel -Dall echo ::: 1
shell? perl /usr/bin/parallel -Dall echo ::: 1
shell? -bash
which -bash => shell path /bin/bash
Academic tradition requires you to cite works you base your article on.
When using programs that use GNU Parallel to process data for publication
please cite:
O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
;login: The USENIX Magazine, February 2011:42-47.
This helps funding further development; AND IT WON'T COST YOU A CENT.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice: run 'parallel --citation'.
Open file descriptors: 2 1
echo Context: Non: 4 Ctxgrp: NonCtxGrp: 1
echo ▒<▒> Context: Non: 4 Ctxgrp: 1 NonCtxGrp: 1
Wanted procs: 16
MultifileQueue->empty RecordQueue->empty CommandLineQueue->empty JobQueue->empty MultifileQueue->empty RecordQueue->empty eval 1
noncontext + command: 5
context+noncontext + command: 5
cmd_line->number_of_args 1
Replace echo ▒<▒>
Target: echoTarget: ▒<▒>Replacing in ▒<▒>
Return echo 1
noncontext + command: 5
context+noncontext + command: 5
noncontext + command: 5
context+noncontext + command: 5
6 == 6 echo 1
Time to fork 1 procs: 0 (processes so far: 1)
MultifileQueue->empty 1 RecordQueue->empty 1CommandLineQueue->empty 1JobQueue->empty 1 RecordQueue-unget ''
JobQueue->empty Limited to procs: 1
JobQueue->empty Running jobs before on ::
: has out of 1 jobs running. Start another.
JobQueue->empty Command to run on ':': 'echo 1'
processes . Starting (1): echo 1
bash -c testfun\(\)\ \{\ rm\ /tmp/parTMasE.tst\;\ \}\;\ export\ -f\ testfun\;\ perl\ -MIPC::Open3\ -e\ if\\\(\\\$pid\\\=::open3\\\(\\\$i,\\\$o,\\\$e,\\\"-\\\"\\\)\\\)\\\ \\\{\\\ wait\\\;\\\ \\\}\\\ else\\\ \\\{\\\ exec\\\(\\\"bash\\\",\\\"-c\\\",\\\"testfun\\\ \\\&\\\&\\\ true\\\"\\\)\\\;\\\ \\\} 2>/dev/null
^Ckill_sleep TERM
kill_sleep TERM
kill_sleep TERM
kill_sleep KILL
Even on running parallel -Dall echo ::: 1 command, I had to CTRL+c to get the prompt back.
As we debugged in the comments your (/usr/local)/bin/rm is not the normal (/usr/local)/bin/rm.

Linux: check if file descriptor is available for reading

Considering the following example, emulating a command which gives output after 10 seconds: exec 5< <(sleep 10; pwd)
In Solaris, if I check the file descriptor earlier than 10 seconds, I can see that it has a size of 0 and this tells me that it hasn't been populated with data yet. I can simply check every second until the file test condition is met (different from 0) and then pull the data:
while true; do
if [[ -s /proc/$$/fd/5 ]]; then
variable=$(cat <&5)
break
fi
sleep 1
done
But in Linux I can't do this (RedHat, Debian etc). All file descriptors appear with a size of 64 bytes no matter if they hold data or not. For various commands that will take a variable amount of time to dump their output, I will not know when I should read the file descriptor. No, I don't want to just wait for cat <&5 to finish, I need to know when I should perform the cat in the first place. Because I am using this mechanism to issue simultaneous commands and assign their output to corresponding file descriptors. As mentioned already, this works great in Solaris.
Here is the skeleton of an idea :
#!/bin/bash
exec 5< <(sleep 4; pwd)
while true
do
if
read -t 0 -u 5 dummy
then
echo Data available
cat <&5
break
else
echo No data
fi
sleep 1
done
From the Bash reference manual :
If timeout is 0, read returns immediately, without trying to read and
data. The exit status is 0 if input is available on the specified file
descriptor, non-zero otherwise.
The idea is to use read with -t 0 (to have zero timeout) and -u 5 (read from file descriptor 5) to instantly check for data availability.
Of course this is just a toy loop to demonstrate the concept.
The solution given by User Fred using only bash builtins works fine, but is a tiny bit non-optimal due to polling for the state of a file descriptor. If calling another interpreter (for example Python) is not a no-go, a non-polling version is possible:
#! /bin/bash
(
sleep 4
echo "This is the data coming now"
echo "More data"
) | (
python3 -c 'import select;select.select([0],[],[])'
echo "Data is now available and can be processed"
# Replace with more sophisticated real-world processing, of course:
cat
)
The single line python3 -c 'import select;select.select([0],[],[])' waits until STDIN has data ready. It uses the standard select(2) system call, for which I have not found a direct shell equivalent or wrapper.

How to receive SIP audio and send wav stream to Google Speech recognition API in node?

So far I've been trying sipster, but it has some forbidding limitations (e.g. lack of configurability). Any ideas how to do this? Maybe with an node wrapper for asterisk like asterisk-manager?
In some more detail the basic idea is
have a virtual sip client running, that can receive a SIP connection
get the audio from that connection into regular wav form
stream that wav audio to the Google speech API
have additional ways to act on the sip stream via node, like play back a sound
This post is quite old, and it looks like things have improved a lot on the Google side, both on the speech processor itself, which is getting more and more accurate, and on the Node.js side, as the Node.js client that interfaces with Google Cloud Speech API is getting updated on a regular basis.
As per #arheops advice, one might want to take a look at Asterisk's EAGI and Node.js in order to get audio samples transcribed by Google.
The following EAGI bash script might help in that regard (detailed instructions available here) :
#!/bin/bash
# Read all variables sent by Asterisk store them as an array, but won't use them
declare -a array
while read -e ARG && [ "$ARG" ] ; do
array=(` echo $ARG | sed -e 's/://'`)
export ${array[0]}=${array[1]}
done
# First argument is language
case "$1" in
"fr-FR" | "en-GB" | "es-ES" | "it-IT" )
LANG=$1
;;
*)
LANG=en-US
;;
esac
NODECMD=$(which node)
# Second argument is a timeout, in seconds. The duration to wait for voice input form the caller.
DURATION=$2
SAMPLE_RATE=8000
SAMPLE_SIZE_BYTES=2
let "SAMPLE_SIZE_BITS = SAMPLE_SIZE_BYTES * 8"
# EAGI_AUDIO_FORMAT is an asterisk variable that specifies the sample rate and
# sample size (usually 16 bits per sample) of the caller's voice stream.
# Depending on the codec used here, you can get sample rate values ranging from
# 8000Hz (e.g. G.711 uLaw) to 48000Hz (e.g. opus).
echo "GET VARIABLE EAGI_AUDIO_FORMAT"
read line
EAGI_AUDIO_FORMAT=$(echo $line | sed -r 's/.*\((.*)\).*/\1/')
# 5 seconds of audio input are gathered in ( SAMPLE_RATE / sample_size ) * 5 bytes
# - SAMPLE_RATE is set as per EAGI_AUDIO_FORMAT
# - sample_size is set to 2 (16 bits per sample)
#
# We don't do much here to adapt the sample rate, this code should be improved
case "${EAGI_AUDIO_FORMAT}" in
"slin48")
SAMPLE_RATE=48000
;;
*)
SAMPLE_RATE=8000
;;
esac
# Temporary file to store raw audio samples
AUDIO_FILE=/tmp/audio-${SAMPLE_SIZE_BITS}_bits-${SAMPLE_RATE}_hz-${DURATION}_sec.raw
# We use `dd` here to copy the raw audio samples we're getting from file
# descriptor 3 (this is the Enhanced version in EAGI) to the temporary file.
# The number of blocks to copy is a function of the DURATION to record audio and
# the sample rate. SAMPLE_SIZE_BYTES cannot be changed as it is assumed that each
# sample is 16 bits in size.
let "COUNT = SAMPLE_RATE * SAMPLE_SIZE_BYTES * DURATION"
# By default, dd stores blocks of 512 bytes
let "BLOCKS = COUNT / 512"
echo "exec noop \"Number of bytes to store : ${COUNT}\""
read line
echo "exec noop \"Number of dd blocks to store : ${BLOCKS}\""
read line
echo "exec playback \"beep\""
read line
dd if=/dev/fd/3 count=${BLOCKS} of=${AUDIO_FILE}
echo "exec noop \"File saved !\""
echo "exec noop \"AUDIO_FILE : ${AUDIO_FILE}\""
read line
echo "exec noop \"SAMPLE_RATE : ${SAMPLE_RATE}\""
read line
echo "exec noop \"LANG : ${LANG}\""
read line
# Submit audio to Google Cloud Speech API and get the result
export GOOGLE_APPLICATION_CREDENTIALS=/usr/local/node_programs/service_account_file.json
RES=$(${NODECMD} /usr/local/node_programs/nodejs-speech/samples/recognize.js sync ${AUDIO_FILE} -e LINEAR16 -r ${SAMPLE_RATE} -l ${LANG})
# clean up result returned from recognize.js :
# - remove new lines
# - remove 'Transcription :' header
RES=$(echo $RES | tr -d '\n' | sed -e 's/Transcription: \(.*$\)/\1/')
# Set GOOGLE_TRANSCRIPTION_RESULT variable, remove temporary file
# and continue dialplan execution
echo "set variable GOOGLE_TRANSCRIPTION_RESULT \"${RES}\""
read line
/bin/rm -f ${AUDIO_FILE}
exit 0
Hope this helps!
Most easy way do that - use asterisk EAGI interface and read sound from stdin/stream to google.
However at current moment google speech recognition api is NOT stable. Some days it just stop working, after that start working next day.

Julius acoustic model on cygwin with HTK

$ HDMan -A -D -T l -m -w wlist -n monophonesl -i -l dlog dict ../lexicon/voxforge_lexicon
C:\cygwin\HTK\htk-3.3-windows-binary\htk\HDMan.exe -A -D -T l -m -w wlist -n monophonesl -i -l dlog dict ../lexicon/voxforge_lexicon
No HTK Configuration Parameters Set
ERROR [+5021] GetChkedInt: Integer Arg Required for T option
FATAL ERROR - Terminating program C:\cygwin\HTK\htk-3.3-windows-binary\htk\HDMan.exe
I am on the third step to train julius using voxforge training. I created lexicon file and global.ded file as mentioned in the text. wheni run the command on cygwin oi get this error. I have been tring stuff but cannot figure it out. can you help me on this.?
-T l
The right command includes number 1, not the letter l. Use
-T 1
To avoid such issues in the future use a font which distinguish them. Copy-paste commands instead of retyping them. Read the message from the tool and try to understand, it already says you where the problem is.

Resources