2017-08-08 37 views
0

當我使用它,它只會說,當我教另一個詞,我不能讓它說目錄中的具體答案,你們有關於如何去解決這個任何意見,我難倒..說話的批處理人工智能(學習),但我有一個問題

@ECHO OFF 
@mode con cols=55 lines=10 
if not exist data.txt echo.>data.txt 
:begin 
set /p text="Talk: " 
for /f "tokens=1,* [email protected]" %%i in (data.txt) do (
if /i "%text%"=="%%i" (

echo Visu: %%j 
goto begin 
) 
) 
:Learn 
    echo --- I don't know that. 
    set /p answer=--- What would be a good answer to '%text%'? 
echo %text%@%answer%>>data.txt 
echo Visu: thank you 
goto Aye 

:Aye 
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "temp.vbs" 
echo speech.speak "%answer%" >> "temp.vbs" 
start temp.vbs 
pause 
del temp.vbs 
goto begin 
+1

使用'echo's調試和看到的是越來越執行什麼樣的代碼,爲什麼你感興趣的代碼是沒有的。如果您仍然無法解決問題,請告訴我們您嘗試過的更多細節。 – vorou

+0

iv字面上嘗試除@LotPings修復程序之外的所有內容。啊哈 –

+0

所以我只是認爲ID有機會尋求幫助,而且它比我打算的更好。 –

回答

0
  • Make Aye是一個子程序/函數,你可以調用文本來說話。
  • 在一個稱爲子第一個參數是%1

@ECHO OFF 
mode con cols=55 lines=10 
if not exist data.txt Type Nul >data.txt 
:begin 
cls& Echo Talk to Visu 
set "text=" & set /p text="Talk: " 
if not defined text exit /B 
for /f "tokens=1,* [email protected]" %%i in (data.txt 
) do if /i "%text%"=="%%i" Call :Aye "%%~j" & Goto :begin 

:Learn 
echo --- I don't know that. 
echo --- What would be a good answer to '%text%' 
set /p answer=? 
echo %text%@%answer%>>data.txt 
Call :Aye "%answer%" 
goto :begin 

:Aye 
echo Visu: %~1 
echo Visu: thank you 
echo set speech = Wscript.CreateObject("SAPI.spVoice") > "temp.vbs" 
echo speech.speak "%~1" >> "temp.vbs" 
cscript //Nologo temp.vbs 
Timeout /T 3 /Nobreak >Nul 
del temp.vbs 
goto :Eof 
+0

非常感謝! –

0

cscript /nologo temp.vbs取代start temp.vbs

,也許你想
echo set speech = Wscript.CreateObject("SAPI.spVoice") > "temp.vbs"
每次(>而不是>>)覆蓋文件?

+0

非常感謝yyou –