Browse Source

TTS完成

张洋 1 month ago
parent
commit
40fbce71db

+ 1 - 1
zhipuzi_pos_windows/page/CWaimaiOrderListPageUI.cpp

@@ -553,7 +553,7 @@ void CWaimaiOrderListPageUI::Hujiaoqucan(CWaimaiOrderItemUI* item)
 	rapidjson::Value& data = document["data"];
 
 	//语音播报
-	CSpeech::MSSSpeak(take_food_code + "号,请取餐!");
+	CSpeech::TTSSpeak(take_food_code + "号,请取餐!");
 }
 
 void CWaimaiOrderListPageUI::Fadan(CWaimaiOrderItemUI* item)

+ 6 - 10
zhipuzi_pos_windows/tool/CSpeech.cpp

@@ -82,19 +82,14 @@ void CSpeech::TXSpeak(std::string content)
 	// 报 "unable to get local issuer certificate" / "Problem with the SSL CA cert" 时,
 	// 设置 TTS_CA_FILE 指向 cacert.pem(可从 https://curl.se/ca/cacert.pem 下载)。
 	const std::string ca_file = "";
-	if (!ca_file.empty())
-	{
-		client.SetCaFile(ca_file);
-	}
-	else
-	{
-		// 本地 demo 默认跳过证书校验,便于先跑通业务逻辑;上生产前一定要开回去。
-		client.SetVerifyPeer(false);
-	}
+	if (!ca_file.empty()) client.SetCaFile(ca_file);
+	// 只有在上面两步都不行、且仅本地调试时,才打开下面这行跳过校验(生产禁用):
+	// client.SetVerifyPeer(false);
 
 	// 必做:把 voice_type 换成你选中的「多情感音色」ID
 	// 音色列表:https://cloud.tencent.com/document/product/1073/92668
-	const int kMyVoiceType = 101026;
+	// 音色试用:https://cloud.tencent.com/product/tts
+	const int kMyVoiceType = 101055;
 
 	const std::string text = content;
 
@@ -194,6 +189,7 @@ void CSpeech::TXSpeak(std::string content)
 			sopt.emotion_category = "story";
 			sopt.emotion_intensity = 120;
 			sopt.speed = 0.0f;
+			sopt.volume = 10.0f;
 			sopt.ca_file = ca_file;   // 上面从 TTS_CA_FILE 读到的,空则走默认查找
 
 			PcmPlayer player;

+ 12 - 7
zhipuzi_pos_windows/tool/CSpeech.h

@@ -6,6 +6,10 @@
 
 #include <sapi.h>
 
+
+/**
+ * 语音合成类,实现文字转语音的功能
+ */
 class CSpeech
 {
 public:
@@ -15,6 +19,14 @@ public:
 	//对外调用的语音合成,可以选择调用腾讯云或者微软的
 	static void TTSSpeak(std::string speakContent);
 
+    /*
+     *把数字拆解成一个个的读音,调用wav文件播放
+     *voice_type 1:收款成功 2:退款成功
+     *num 金额,比如18.23
+     **/
+	static void SpeakNum(int voice_type, std::string num);
+
+private:
 	// 基于微软的TTS
 	static void MSSSpeak(std::string content);
 
@@ -30,11 +42,4 @@ public:
 	 *读一个整数
 	 **/
 	static void SpeakInt(int num);
-
-    /*
-     *把数字拆解成一个个的读音,调用wav文件播放
-     *voice_type 1:收款成功 2:退款成功
-     *num 金额,比如18.23
-     **/
-	static void SpeakNum(int voice_type, std::string num);
 };