2016-06-17 16 views
0

私はテキスト読み上げで作業中で、オーディオファイルを生成しようとしています。私は現在、PicoTTS on Linux(Raspberry Pi)に取り組んでいます。 次のコマンドは:テキスト読み上げの文字列または変数値(PicoTTS)

system("pico2wave -w res.wav "Hello to all of you"); 
    system("aplay res.wav"); 

上記のコードは、「あなたのすべてにこんにちは」遊ぶん。しかし、私はstringに格納されたコンテンツを再生したい、wstring(変数を読み込む)。

私はそれがbufに格納された値BUFを果たし、ない

sprintf(buf, "Hello to all of you"); 
    system("pico2wave -w res.wav buf); 
    system("aplay res.wav"); 

を試してみました。 文字列値を受け入れるピコ以外のTTSを使用することをお勧めしますか?それが価値をも果たすことができれば、私にとって大きな助けになるでしょう。 私はRaspberry Pi 2とC++を使用しています。

答えて

1

システムコールの前に文字列を連結し、その連結文字列をシステムコールに使用する必要があります。 whatever the user enteredニーズが"whatever the user entered"のように引用符でラップされる場合には、その後

command += text_to_say; 

になる

std::string command = "pico2wave -w res.wav "; 
std::string text_to_say; 
// get input from user and store it into text_to_say 
command += text_to_say; 
// now command is pico2wave -w res.wav whatever the user entered 
system(command.c_str()); 
system("aplay res.wav"); 

ようになり

command += "\"" + text_to_say + "\""; 
+0

ありがとうございました。 – RDoonds

0

私は仕事ができると仮定し(注意:コードがテストされていません)

// command string 
std::string cmd("pico2wave -w res.wav "); 

// create the message in some way 
std::string msg("Hello to all of you"); 

// call to system 
system((cmd+"\""+msg+"\"").c_str()); 
関連する問題