Using equivalent bash script for Windows batch file
Using equivalent bash script for Windows batch file
I have a Windows commandline application which I want to run with WINE. It's a text to mp3 converter. I have a Windows batch script which I want to use to convert all the text files in a folder to mp3. This is the batch script:
set filter="C:\Program Files\2nd Speech Center\Documents\*.txt"
for %%i in (%filter%) do ttscmd.exe /ttm "%%i" -s 162 -w 128 -r 16 -b 16 -q 7
In my Puppy setup the *.txt files will be in /mnt/sda3/Audiobook and
ttscmd.exe will be in "/2nd Speech Center"
I can get the commandline to work for the conversion of one file at a time, eg: wine "/2nd Speech Center/ttscmd.exe" /ttm "/mnt/sda3/Audiobooks/01 The Fallen - David Baldacci.txt" "/mnt/sda3/Audiobooks/01 The Fallen - David Baldacci.mp3" -s 162 -w 128 -r 16 -b 16 -q 7
I need a bash script for this and any help will be appreciated as I just can't get it working. Thanks.
set filter="C:\Program Files\2nd Speech Center\Documents\*.txt"
for %%i in (%filter%) do ttscmd.exe /ttm "%%i" -s 162 -w 128 -r 16 -b 16 -q 7
In my Puppy setup the *.txt files will be in /mnt/sda3/Audiobook and
ttscmd.exe will be in "/2nd Speech Center"
I can get the commandline to work for the conversion of one file at a time, eg: wine "/2nd Speech Center/ttscmd.exe" /ttm "/mnt/sda3/Audiobooks/01 The Fallen - David Baldacci.txt" "/mnt/sda3/Audiobooks/01 The Fallen - David Baldacci.mp3" -s 162 -w 128 -r 16 -b 16 -q 7
I need a bash script for this and any help will be appreciated as I just can't get it working. Thanks.
You need something like this:
Should get you close..
Code: Select all
#!/bin/bash
# This command produces the list of .txt files
LIST=$(ls /mnt/sda3/Audiobooks/*.txt)
IFS=$'\n'
for Line in $LIST # Loop through the list
do
MP3_Out=$(echo $Line | cut -d '.' -f1)".mp3" # change .txt extension to .mp3
wine "/2nd Speech Center/ttscmd.exe" /ttm "$Line" "$MP3_Out" -s 162 -w 128 -r 16 -b 16 -q 7
done
Unfortunately that didn't work. The /ttm argument in the command already directs that the output will be in mp3 format. I don't know if that helps any. The script must find the .txt files and the mp3 output names must be the same as those of the corresponding .txt files, so eg: 1.txt becomes 1.mp3 after text to speech conversion and so on.
- puppy_apprentice
- Posts: 299
- Joined: Tue 07 Feb 2012, 20:32
Your batch:
Try this or ask mushero:
Code: Select all
set filter="C:\Program Files\2nd Speech Center\Documents\*.txt"
for %%i in (%filter%) do (
ttscmd.exe /ttm "%%i" -s 162 -w 128 -r 16 -b 16 -q 7
)
Code: Select all
#!/bin/bash
# This command produces the list of .txt files
LIST=$(ls /mnt/sda3/Audiobooks/*.txt)
IFS=$'\n'
for Line in $LIST # Loop through the list
do
wine "/2nd Speech Center/ttscmd.exe" /ttm "$Line" -s 162 -w 128 -r 16 -b 16 -q 7
done
- puppy_apprentice
- Posts: 299
- Joined: Tue 07 Feb 2012, 20:32
Go to:
and open console there (in ROX filer `) and try:
Code: Select all
/mnt/sda3/Audiobooks/
Code: Select all
#!/bin/bash
# This command produces the list of .txt files
LIST=$(ls *.txt)
IFS=$'\n'
for Line in $LIST # Loop through the list
do
wine "/2nd Speech Center/ttscmd.exe" /ttm "$Line" -s 162 -w 128 -r 16 -b 16 -q 7
done
No-no, Puppy_Apprentice.puppy_apprentice wrote:Try this or ask mushero:Code: Select all
#!/bin/bash # This command produces the list of .txt files LIST=$(ls /mnt/sda3/Audiobooks/*.txt) IFS=$'\n' for Line in $LIST # Loop through the list do wine "/2nd Speech Center/ttscmd.exe" /ttm "$Line" -s 162 -w 128 -r 16 -b 16 -q 7 done
"Tray" this. (Inside joke between Puppy_Apprentice and me!!!)
As for me, I'd do it the old-fashioned way:
Enter the directory
Create a one-column list of the files
Loop through the files list to play them
Remove the list file when finished.
Code: Select all
cd /mnt/sda3/Audiobooks
ls -1 *.txt > list # No need to use or alter IFS if using < ls -1 >.
# Change "list" to something more telling if you wish.
while read line;do
wine "/2nd Speech Center/ttscmd.exe" /ttm "$line" -s 162 -w 128 -r 16 -b 16 -q 7
done < list # We do the job.
rm -f list # We clean up.
should do the job, IMO.
IHTH
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
- puppy_apprentice
- Posts: 299
- Joined: Tue 07 Feb 2012, 20:32
Another try:
1) Make a script try_me.sh. Put at the first line:
2) Save this:
as script eg. intermediate.sh in the same dir with try_me.sh, you should get script like your working one liner example:
3) Execute try_me.sh
1) Make a script try_me.sh. Put at the first line:
Code: Select all
#!/bin/bash
Code: Select all
#!/bin/bash
# This command produces the list of .txt files
LIST=$(ls /mnt/sda3/Audiobooks/*.txt)
IFS=$'\n'
for Line in $LIST # Loop through the list
do
MP3_Out=$(echo $Line | cut -d '.' -f1)".mp3" # change .txt extension to .mp3
echo wine \""/2nd Speech Center/ttscmd.exe"\" /ttm "$Line" "$MP3_Out" -s 162 -w 128 -r 16 -b 16 -q 7 >>try_me.sh
done
Code: Select all
#!/bin/bash
wine "/2nd Speech Center/ttscmd.exe" /ttm "/mnt/sda3/Audiobooks/01 The Fallen - David Baldacci.txt" "/mnt/sda3/Audiobooks/01 The Fallen - David Baldacci.mp3" -s 162 -w 128 -r 16 -b 16 -q 7
wine "/2nd Speech Center/ttscmd.exe" /ttm "/mnt/sda3/Audiobooks/02 xxxx - yyyy.txt" "/mnt/sda3/Audiobooks/02 xxxx - yyyy.mp3" -s 162 -w 128 -r 16 -b 16 -q 7
etc.
I dont have ttscmd.exe .
Nic007 wanted a conversion from txt to mp3.
Nic007 wrote that both jafadmins and Musher0s code works.
Jafadmins wine call specifies xxx.txt xxx.mp3
Musher0s wine call just specifies the xxx.txt
=============
Some questions:
Q:Does Musher0s wine-call produce persistent mp3-files? (a default behaviour of ttscmd.exe ?)
---
Q:Will
/TMPDIR/xxx.txt /PERSISTENTDIR/xxx.mp3
i.e jafadmins approach with different in-/output PATHS
work?
------
Nic007?
Q: Has puppy_apprentices code- try_me.sh-been tested with real txt-files?
(By the look -I guess it will run - but I cannot test it)`
----
Nic007 wanted a conversion from txt to mp3.
Nic007 wrote that both jafadmins and Musher0s code works.
Jafadmins wine call specifies xxx.txt xxx.mp3
Musher0s wine call just specifies the xxx.txt
=============
Some questions:
Q:Does Musher0s wine-call produce persistent mp3-files? (a default behaviour of ttscmd.exe ?)
---
Q:Will
/TMPDIR/xxx.txt /PERSISTENTDIR/xxx.mp3
i.e jafadmins approach with different in-/output PATHS
work?
------
Nic007?
Q: Has puppy_apprentices code- try_me.sh-been tested with real txt-files?
(By the look -I guess it will run - but I cannot test it)`
----