55fb0896b8
Fay2.0: 1、控制器pc内网穿透,音频输入输出设备远程直连; 2、提供android 音频输入输出工程示例代码; 3、提供python音频输入输出工程示例代码(远程PC、树莓派等可用); 4、补传1.0语音指令音乐播放模块(暂不支持远程播放); 5、重构及补充若干工具模块:websocket、多线程、缓冲器、音频流录制器等; 6、修复1.x版本的多个bug。
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
import os
|
|
import json
|
|
import codecs
|
|
from configparser import ConfigParser
|
|
|
|
|
|
config: json = None
|
|
system_config: ConfigParser = None
|
|
system_chrome_driver = None
|
|
key_ali_nls_key_id = None
|
|
key_ali_nls_key_secret = None
|
|
key_ali_nls_app_key = None
|
|
key_ms_tts_key = None
|
|
Key_ms_tts_region = None
|
|
key_xf_aiui_app_id = None
|
|
key_xf_aiui_api_key = None
|
|
key_xf_ltp_app_id = None
|
|
key_xf_ltp_api_key = None
|
|
key_ngrok_cc_id = None
|
|
|
|
def load_config():
|
|
global config
|
|
global system_config
|
|
global system_chrome_driver
|
|
global key_ali_nls_key_id
|
|
global key_ali_nls_key_secret
|
|
global key_ali_nls_app_key
|
|
global key_ms_tts_key
|
|
global key_ms_tts_region
|
|
global key_xf_aiui_app_id
|
|
global key_xf_aiui_api_key
|
|
global key_xf_ltp_app_id
|
|
global key_xf_ltp_api_key
|
|
global key_ngrok_cc_id
|
|
|
|
system_config = ConfigParser()
|
|
system_config.read('system.conf', encoding='UTF-8')
|
|
system_chrome_driver = os.path.abspath(system_config.get('system', 'chrome_driver'))
|
|
key_ali_nls_key_id = system_config.get('key', 'ali_nls_key_id')
|
|
key_ali_nls_key_secret = system_config.get('key', 'ali_nls_key_secret')
|
|
key_ali_nls_app_key = system_config.get('key', 'ali_nls_app_key')
|
|
key_ms_tts_key = system_config.get('key', 'ms_tts_key')
|
|
key_ms_tts_region = system_config.get('key', 'ms_tts_region')
|
|
key_xf_aiui_app_id = system_config.get('key', 'xf_aiui_app_id')
|
|
key_xf_aiui_api_key = system_config.get('key', 'xf_aiui_api_key')
|
|
key_xf_ltp_app_id = system_config.get('key', 'xf_ltp_app_id')
|
|
key_xf_ltp_api_key = system_config.get('key', 'xf_ltp_api_key')
|
|
key_ngrok_cc_id = system_config.get('key', 'ngrok_cc_id')
|
|
|
|
config = json.load(codecs.open('config.json', encoding='utf-8'))
|
|
|
|
|
|
def save_config(config_data):
|
|
global config
|
|
config = config_data
|
|
file = codecs.open('config.json', mode='w', encoding='utf-8')
|
|
file.write(json.dumps(config, sort_keys=True, indent=4, separators=(',', ': ')))
|
|
file.close()
|
|
# for line in json.dumps(config, sort_keys=True, indent=4, separators=(',', ': ')).split("\n"):
|
|
# print(line)
|