hello,
could someone help me to run a .mp3 audio file by some bash script?
thank you in advance
run an audio file by bash script [ SOLVED ]
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
run an audio file by bash script [ SOLVED ]
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: run an audio file by bash script
Install mpg123 and then you can play an mp3 file with
mpg123 [i]/path/to/file.mp3[/i]
. See mpg123 --help
for summary of options or man mpg123
for detailed description of options.Re: run an audio file by bash script
I have install mpg123 and it works.
but my wish was that I write just one script that execute the following tasks:
1 run a given audio file in background
2 after 5 seconds greets me with: "Hello, Tony!"
I came to the conclusion that for this purpose the script should look like this:
#!/bin/bash
mpg123 /home/music/lenny1.mp3
sleep 5
echo "Hello, Tony!"
the problem here is that if I run exactly such file the audio lenny.mp3 will start and the bash will execute the next command just when the audio comes to end. if the audio file has a duration of 15:20 m I should wait for 15 min. to see the greeting.
I would like to write such a script that brings the os to run lenny.mp3 as a single separate process running in a background and then ( after 5 seconds ) I want that bash gives me the greeting "Hello, Tony!" without having to wait 15 min.
is it possible?
but my wish was that I write just one script that execute the following tasks:
1 run a given audio file in background
2 after 5 seconds greets me with: "Hello, Tony!"
I came to the conclusion that for this purpose the script should look like this:
#!/bin/bash
mpg123 /home/music/lenny1.mp3
sleep 5
echo "Hello, Tony!"
the problem here is that if I run exactly such file the audio lenny.mp3 will start and the bash will execute the next command just when the audio comes to end. if the audio file has a duration of 15:20 m I should wait for 15 min. to see the greeting.
I would like to write such a script that brings the os to run lenny.mp3 as a single separate process running in a background and then ( after 5 seconds ) I want that bash gives me the greeting "Hello, Tony!" without having to wait 15 min.
is it possible?
Re: run an audio file by bash script
Yes, add a & at the end of the mpg123 command to run it in the background. As such:
You may also want to use -q (I think) option of mpg123 to make it not output text on the terminal. Or else replace the command with this to make it not output text (&>/dev/null means send both stdout and stderr to the everlasting bit bucket):
mpg123 /home/music/lenny1.mp3 &
You may also want to use -q (I think) option of mpg123 to make it not output text on the terminal. Or else replace the command with this to make it not output text (&>/dev/null means send both stdout and stderr to the everlasting bit bucket):
mpg123 /home/music/lenny1.mp3 &>/dev/null &
Re: run an audio file by bash script
I have added & to the line mpg123 /home/music/lenny1.mp3 and now it works really gut!
just ... one little detail. ( hopefully I am not too impudent )
is it possible to write such script that will make things so that bash will not show in the command line the following message:
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
version 1.16.0; written and copyright by Michael Hipp and others
free software (LGPL) without any warranty but with best wishes
Directory: /home/music/lenny1.mp3
Playing MPEG stream 1 of 1: lynar.mp3 ...
MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo
just ... one little detail. ( hopefully I am not too impudent )
is it possible to write such script that will make things so that bash will not show in the command line the following message:
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
version 1.16.0; written and copyright by Michael Hipp and others
free software (LGPL) without any warranty but with best wishes
Directory: /home/music/lenny1.mp3
Playing MPEG stream 1 of 1: lynar.mp3 ...
MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo
Re: run an audio file by bash script
I already answered that
xenopeek wrote:You may also want to use -q (I think) option of mpg123 to make it not output text on the terminal. Or else replace the command with this to make it not output text (&>/dev/null means send both stdout and stderr to the everlasting bit bucket):
mpg123 /home/music/lenny1.mp3 &>/dev/null &
Re: run an audio file by bash script
so.
mpg123 --quiet --scale 1000 --loop -1 /home/music/lennny1.mp3 &
sleep 6
spd-say hi,,tony
echo "hi, tony!"
and one almost have the feeling he just created his own homemade A. I. !
I am not sure that this is possible with windows. that's why linux is cool! not bad.
mpg123 --quiet --scale 1000 --loop -1 /home/music/lennny1.mp3 &
sleep 6
spd-say hi,,tony
echo "hi, tony!"
and one almost have the feeling he just created his own homemade A. I. !
I am not sure that this is possible with windows. that's why linux is cool! not bad.