#include "tts/piper_tts_interface.h" #include #include int main() { // 使用默认配置 (piper 和 /app/piper_models/zh_CN-huayan-medium.onnx) PiperTTSInterface tts_speaker; // 如果你的piper可执行文件不在PATH中,或者模型路径不同,你可以这样指定: // PiperTTSInterface tts_speaker("/path/to/your/piper_executable", "/path/to/your/model.onnx"); std::string text_to_say = "请执行上述调试步骤,特别是禁用文件删除后手动检查和播放 WAV 文件,这将提供更多线索"; if (tts_speaker.say_text_and_play(text_to_say)) { std::cout << "语音播报完成。" << std::endl; } else { std::cerr << "语音播报失败,请检查日志。" << std::endl; } return 0; } // #include // #include // #include // #include "systemMonitor/iio_sensor.h" // 包含我们刚刚创建的头文件 // int main() { // // --- 配置参数 --- // // !!! 修改这里以匹配你的设备和通道 !!! // const std::string iio_device_path = "/sys/bus/iio/devices/iio:device0"; // const std::string iio_channel_name = "in_voltage2_raw"; // 例如,连接到 IN2 通道 // const double adc_reference_voltage = 1.8; // ADC参考电压 // const int64_t adc_resolution = 4096; // ADC分辨率 (e.g., 2^12 for 12-bit) // const double signal_gain = 11.0; // 信号通路的增益 // std::cout << "--- Starting IIO Sensor Reader (Version 2) ---" << std::endl; // std::cout << "Reading from device: " << iio_device_path << std::endl; // std::cout << "Reading channel: " << iio_channel_name << std::endl; // std::cout << "-----------------------------------------------" << std::endl; // // 注意:传感器对象在 try 块外创建,如果构造失败(找不到文件),会立即被捕获 // IioSensor sensor(iio_device_path, iio_channel_name); // while (true) { // try { // // 封装后的调用方式非常简洁! // // 每次调用 readVoltage,内部都会重新打开文件读取一次 // double actual_voltage = sensor.readVoltage(adc_reference_voltage, adc_resolution, signal_gain); // // 输出结果 // std::cout << "Actual Voltage: " << actual_voltage << " V" << std::endl; // } catch (const IioSensorError& e) { // // 如果单次读取失败(例如文件内容格式错误、无权限等),打印错误但继续循环 // std::cerr << "[!] Read Error: " << e.what() << std::endl; // } // // 每秒钟读取一次 // std::this_thread::sleep_for(std::chrono::seconds(1)); // } // return 0; // }