游雁
2023-08-30 c2e4e3c2e9be855277d9f4fa9cd0544892ff829a
funasr/runtime/wss-client/FunASRWSClient_Offline/Program.cs
@@ -19,11 +19,13 @@
    {
        public static string host = "0.0.0.0";
        public static string port = "10095";
        public static string hotword = null;
        private static CWebSocketClient m_websocketclient = new CWebSocketClient();
        [STAThread]
        public async void FunASR_Main()
        {
            loadconfig();
            loadhotword();
            //初始化通信连接
            string errorStatus = string.Empty;
            string commstatus = ClientConnTest();
@@ -72,6 +74,34 @@
                    }
                }
            }
        }
        static void loadhotword()
        {
            string filePath = "hotword.txt";
            try
            {
                // 使用 StreamReader 打开文本文件
                using (StreamReader sr = new StreamReader(filePath))
                {
                    string line;
                    // 逐行读取文件内容
                    while ((line = sr.ReadLine()) != null)
                    {
                        hotword += line;
                        hotword += " ";
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("读取文件时发生错误:" + ex.Message);
            }
            finally
            {
                if (hotword.Length > 0 && hotword[hotword.Length - 1] == ' ')
                    hotword = hotword.Substring(0,hotword.Length - 1);
            }
        }
        private static string ClientConnTest()
        {