@echo off
@title=【鬍子作品】世界最小批處理語音軟體 v2.0
:begin
@cls
echo ┏━━━━━━━━━━━━━━━━━━┓
echo.
echo 【世界上最小的語音朗讀軟體】
echo 鬍子軟體工作室·榮譽出品
echo.
echo 1.中英文朗讀均可
echo 2.需要先在控制台中設定預設語音
echo 3.可以選擇是否同時錄音
echo 4.文本每個段落不大於1024個字元
echo.
echo ┗━━━━━━━━━━━━━━━━━━┛
@echo. & echo.
color 0B
@set /p fn="●請輸入朗讀文本所在文字檔名:"
if not exist
%fn% echo. & echo ◆檔案不存在! & echo. & pause & goto begin
echo.
set /p yn="●是否同時產生語音檔案(Y/N):"
if /i
%yn%==n goto read
echo.
echo ●正在讀入文本,請稍候……
echo Const ForReading
= 1 >ly.vbs
echo Set objFSO
= CreateObject("Scripting.FileSystemObject")
>>ly.vbs
echo Set objTextFile
= objFSO.OpenTextFile(Wscript.Arguments(0), ForReading)
>>ly.vbs
echo strText
= objTextFile.ReadAll >>ly.vbs
echo Const SSFMCreateForWrite
= 3 >> ly.vbs
echo Set objVoice
= CreateObject("SAPI.SpVoice")
>>ly.vbs
echo Set objFile
= CreateObject("SAPI.SpFileStream.1")
>>ly.vbs
echo objFile.Open "C:\Test.wav", SSFMCreateForWrite
>>ly.vbs
echo Set objVoice.AudioOutputStream
= objFile >>ly.vbs
echo set objshell=createobject("wscript.shell")
>>ly.vbs
echo objVoice.Speak strText
>>ly.vbs
echo objTextFile.Close
>>ly.vbs
ly.vbs
%fn%
:read
echo.
echo ●按任意鍵開始朗讀……
pause>nul
echo.
for /f "tokens=*"
%%a in
(%fn%) do echo %%a
& echo. & start /wait "" mshta vbscript:CreateObject("SAPI.SpVoice").Speak("%%a")(Window.close)
@echo.
@echo ●朗讀完畢!產生的語音檔案儲存在 C:\test.wav
@echo.
:end
@echo ●按任意鍵退出
pause>nul
@echo on
@del ly.vbs
-----------------------------------