Code: Select all
LinePause := "This is a break."
FileSelectFile, SelectedFile,, %A_ScriptDir%,Select File ,*.txt
If (ErrorLevel)
return
Loop % SelectedFile
strFileName := strSplit(A_LoopFileName, ".txt")[1]
FileRead, filecontent, %SelectedFile%
lineCount := 0
Loop, Parse, fileContent, `n
lineCount++
TextZeilenAnzahl := strSplit(fileContent , "`n").length()
strWav := A_Yday "_" (A_hour*60 + A_min) "_" strFileName ".wav"
strMP3 := A_Yday "_" (A_hour*60 + A_min) "_" strFileName ".mp3"
spVoice := ComObjCreate("SAPI.SpVoice")
spVoice.Volume := 100
spVoice.Rate := -3
spVoice.Voice := spVoice.GetVoices().Item(0) ; Set language
spVoice.AllowAudioOutputFormatChangesOnNextSet := 1
AllVoices := []
Loop, % spVoice.GetVoices.Count
{
Name := spVoice.GetVoices.Item(A_Index-1).GetAttribute("Name") ; 0 based
VoiceList .= A_Index - 1 "`t" Name "`n" ; Nullbasiert deshalb: A_Index - 1
AllVoices.push(Name)
}
InputBox, output, Choose voice,%VoiceList% ,, 400,400, 600, 50,,
If (ErrorLevel)
return
spVoice.Voice := spVoice.GetVoices().Item(4)
spStream := ComObjCreate("SAPI.SpFileStream")
SpStream.Open(strWav,3,1)
spVoice.AudioOutputStream := spStream
loop % strSplit(fileContent , "`n").length() ; lineCount
{
spVoice.Volume := 100 ;
FileReadLine, LineContent, %SelectedFile%, A_Index
spVoice.Speak(LineContent)
spVoice.Volume := 0
spVoice.Speak(LinePause)
}
spVoice.AudioOutputStream.Close()
; No matter if I want to convert the wav file with lame.exe or ffmpeg.exe, the error occurs here:
RunWait, ffmpeg.exe -i "%strWav%" "%strMP3%" ,, Hide ; Error here
RunWait, lame.exe -V2 "%strWav%" "%strMP3%",, Hide ; Error here