Advertisement
Guest User

say.bat piper

a guest
Apr 16th, 2024
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.49 KB | Software | 0 0
  1. @echo off
  2. Rem define initial variables
  3. set speaker=en-gb-southern_english_female-low.onnx
  4. set argum=%*
  5.  
  6. Rem output folder:
  7. set place=r:\
  8.  
  9. Rem check if the bat file was double clicked from the explorer:
  10. IF /I %0 EQU "%~dpnx0" (
  11. set argum=Please run this batch command from the commandline ! ? .
  12. echo Please run this batch command from the commandline !
  13. goto :continueloop
  14. )
  15.  
  16. Rem check if the bat file has runned without parameters, and display the info:
  17. if "%1"=="" (
  18. echo.
  19. echo usage: say [voice:] text
  20. echo.
  21. echo Voices
  22. echo German: eva: kar: ker: pav: ram: tho:
  23. echo En-GB: ala: sen:
  24. Echo EN-US: amy: danny: kath: less: libri: ryanlow: ryanhi:
  25. echo.
  26. echo This needs the piper.exe and ffplay.exe to speak the words !
  27. echo The wav file is saved in the %place% folder, change it to the desired location!
  28. goto :theend
  29. )
  30.  
  31. Rem assign voice definitions from %1:
  32. if "%1"=="eva:" (
  33. set speaker=de-eva_k-x-low.onnx
  34. goto :getloop
  35. )
  36.  
  37. if "%1"=="kar:" (
  38. set speaker=de-karlsson-low.onnx
  39. goto :getloop
  40. )
  41.  
  42. if "%1"=="ker:" (
  43. set speaker=de-kerstin-low.onnx
  44. goto :getloop
  45. )
  46.  
  47. if "%1"=="pav:" (
  48. set speaker=de-pavoque-low.onnx
  49. goto :getloop
  50. )
  51.  
  52. if "%1"=="ram:" (
  53. set speaker=de-ramona-low.onnx
  54. goto :getloop
  55. )
  56.  
  57. if "%1"=="tho:" (
  58. set speaker=de-thorsten-low.onnx
  59. goto :getloop
  60. )
  61.  
  62. if "%1"=="ala:" (
  63. set speaker=en-gb-alan-low.onnx
  64. goto :getloop
  65. )
  66.  
  67. if "%1"=="sen:" (
  68. set speaker=en-gb-southern_english_female-low.onnx
  69. goto :getloop
  70. )
  71.  
  72. if "%1"=="amy:" (
  73. set speaker=en-us-amy-low.onnx
  74. goto :getloop
  75. )
  76.  
  77. if "%1"=="danny:" (
  78. set speaker=en-us-danny-low.onnx
  79. goto :getloop
  80. )
  81.  
  82. if "%1"=="kath:" (
  83. set speaker=en-us-kathleen-low.onnx
  84. goto :getloop
  85. )
  86.  
  87. if "%1"=="less:" (
  88. set speaker=en-us-lessac-low.onnx
  89. goto :getloop
  90. )
  91.  
  92. if "%1"=="libri:" (
  93. set speaker=en-us-libritts-high.onnx
  94. goto :getloop
  95. )
  96.  
  97. if "%1"=="ryanlow:" (
  98. set speaker=en-us-ryan-low.onnx
  99. goto :getloop
  100. )
  101.  
  102. if "%1"=="ryanhi:" (
  103. set speaker=en-us-ryan-high.onnx
  104. goto :getloop
  105. )
  106.  
  107. Rem Create the wav file with the piper.exe
  108. :continueloop
  109. echo.
  110. echo ? .   %argum% . . . | piper.exe -q -m %speaker% -f %place%speakingoutput.wav
  111.  
  112. rem and play it with the ffplay.exe, replace it with a player of your choice:
  113. ffplay -hide_banner -loglevel panic -nodisp -autoexit %place%speakingoutput.wav
  114.  
  115. goto :theend
  116.  
  117. Rem remove the first parameter (voice name) and assing the rest into argum variable
  118. :getloop
  119. for /f "tokens=1,* delims= " %%a in ("%*") do set argum=%%b
  120. goto :continueloop
  121.  
  122. Rem end the batch file
  123. :theend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement