I am trying to stream the recorded audio from my raspberry pis to my desktop computer which handles pocketsphinx phenomenally. I can pipe the audio using
arecord -D plughw:1,0 -r 16000 -f S16_LE | ssh -C user#192.168.86.101 sox - test.wav
And then run it using
pocketsphinx_continuous -dict ~/4568.dic -lm ~/4568.lm -infile ~/test.wav
But once it reaches the end of the file, it stops, even though the file is still writing. Is there a way to keep it open?
Use named pipe instead of a regular file. Also you can file an issue at github.com/cmusphinx/pocketsphinx requesting that pocketsphinx_continious should be able to read from stdin. And of course you're welcome to submit such a patch.
To anyone else finding this,
arecord -D plughw:1,0 -r 16000 -f S16_LE | ssh -C user#192.168.86.101 pocketsphinx_continuous -infile /dev/stdin
is how to do it
Related
Does any one know how to merge multiple raw audio file into single wav file. I am using Sox but any other tools also fine.
I am trying below commands, but i know something wrong here
sox -r 16000 -b 16 -c 1 -e signed-integer file1.raw file2.raw out.wav
I am missing something ?
You need to specify all input file parameters per file (as RAW obviously does not have a header). Your initial guess was same as mine: that -r 16000 -b 16 -c 1 -e signed-integer applies to both file1.raw and file2.raw. It doesn't.
Here's how it should be done:
sox -r 16000 -b 16 -c 1 -e signed-integer file1.raw -r 16000 -b 16 -c 1 -e signed-integer file2.raw out.wav
You might want to add option -m for merge.
I'm saving an fm station to an mp3 file using rtl_fm and sox.
rtl_fm to capture the signal and sox to transcode it to mp3.
rtl_fm -M wbfm -f 88.1M -d 0 -s 22050k -l 310 | sox -traw -r8k -es -b16 -c1 -V1 - -tmp3 - | sox -tmp3 - some_file.mp3
Then I'm trying to play that file in a second terminal, as the mp3 is being written using:
play -t mp3 some_file.mp3
The problem is that it only plays up until the time the mp3 had at the time the play command was invoked.
How do I get it to play the appended mp3 over time, while it's being written?
EDIT:
Running on Raspberry Pi 3 (Raspian Jessie), NooElec R820T SDR
There are a couple of things here. I don't think sox supports "tailing" a file, but I know mplayer does. However, in order to have better control over the pipeline, using gstreamer might be the way to go, as it has a parallel event stream built into its effects pipeline.
If you want to stick with sox, I would first get rid of the redundant second invocation of sox, e.g.:
rtl_fm -M wbfm -f 88.1M -d 0 -s 22050k -l 310 |
sox -ts16 -r8k -c1 -V1 - some_file.mp3
And in order to play the stream while transcoding it, you could multiplex it with tee, e.g.:
rtl_fm -M wbfm -f 88.1M -d 0 -s 22050k -l 310 |
tee >(sox -ts16 -r8k -c1 -V1 - some_file.mp3) |
play -ts16 -r8k -c1 -
Or if you want them to be separate processes:
# Save stream to a file
rtl_fm -M wbfm -f 88.1M -d 0 -s 22050k -l 310 > some_file.s16
# Encode stream
sox -ts16 -r8k -c1 -V1 some_file.s16 some_file.mp3
# Start playing the file at 10 seconds in
tail -c+$((8000 * 10)) -f some_file.s16 |
play -ts16 -r8k -c1 -
Is it possible to check if a video file has a subtitle using bash and get a simple answer like "yes" or "no". I don't need to know any details about the subtitles.
Maybe using ffmpeg?
This should display a 0 if subtitles are found, and 1 if not found.
ffmpeg -i video -c copy -map 0:s:0 -frames:s 1 -f null - -v 0 -hide_banner; echo $?
Bash
ffmpeg -i $filename 2>&1 | grep "Subtitle:"
Powershell
ffmpeg -i $filename 2>&1 | select-string "Subtitle:"
Explanation:
The ffmpeg command fails if no output file is provided, but the error message contains all information about the input file. The expression 2>&1 redirects error stream to standard output so it can be piped into grep/select-string command.
I'm using this command to record audio in Linux Fedora 23
/usr/bin/arecord -d 11400 -D hw:1,0 -f S32_LE -c2 -r48000 -t wav | lame -b 192 - longrec.mp3 >> output.txt 2>&1 & echo $!
Basically I want an mp3 record of 3 hours and 10 minutes (11400 seconds) from the input soundcard. Everything works fine when started, but it always stops after 1h33m12s. File output.txt shows nothing of any interest:
LAME 3.99.5 64bits (http://lame.sf.net)
Using polyphase lowpass filter, transition band: 18774 Hz - 19355 Hz
Encoding <stdin> to longrec.mp3
Encoding as 48 kHz j-stereo MPEG-1 Layer III (8x) 192 kbps qval=3
Any clue of what the problem is?
[SOLVED] instead of using arecord I have switched to ffmpeg, command:
ffmpeg -f pulse -i alsa_input.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo -t 11400 -c:a libmp3lame -b:a 192k longrec.mp3
Has the same effect as arecord one and it also doesn't block sound-card resource (I can run multiple ffmpeg record instance from the same source, while with arecord I can do only one).
Is there a way to hide the output of the aplay command when play a sound?
I tried this without success
$ aplay ~/.zsh/sounds/done.wav >> /dev/null
Playing WAVE '/home/oscar/.zsh/sounds/done.wav' : Unsigned 8 bit, Rate 11025 Hz, Mono
I'll appreciate your help.
Simply add the -q option:
aplay -q ~/.zsh/sounds/done.wav
No need to redirect stdout to /dev/null there.
Another note: aplay actuall sends messages to /dev/stderr (fd 2). You can also nullify the output by sending it to /dev/null:
aplay ~/.zsh/sounds/done.wav 2>/dev/null
You can see more options with aplay --help. This line is about -q:
-q, --quiet quiet mode