2025-10-17 09:58:16 +08:00
|
|
|
#include "piper_tts_interface.h"
|
|
|
|
|
#include <string>
|
2025-10-13 13:55:15 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2025-10-16 17:42:59 +08:00
|
|
|
int main() {
|
2025-10-17 09:58:16 +08:00
|
|
|
PiperTTSInterface tts_processor;
|
|
|
|
|
// 示例 1: 只提供文本和输出文件名
|
|
|
|
|
std::string text1 = "你好,世界。温度传感器出现故障。只需输入文本即可。";
|
|
|
|
|
std::string file1 = "hello_world.wav";
|
|
|
|
|
if (tts_processor.text_to_speech(text1, file1)) {
|
|
|
|
|
std::cout << "Audio for '" << text1 << "' generated successfully!" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
std::cerr << "Failed to generate audio for '" << text1 << "'." << std::endl;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|