Compare commits

...

3 Commits

Author SHA1 Message Date
IrvingGao 77ad5887d0 Update code for release v0.9.1 2024-07-15 14:53:50 +08:00
IrvingGao d15f5a55cb [doc] update readme 2024-07-08 16:55:09 +08:00
IrvingGao 5512fe7735 [port] update port 2024-07-08 16:52:13 +08:00
4 changed files with 27 additions and 63 deletions

View File

@ -23,7 +23,7 @@ sudo apt-get install -y git swig python3-pip python3-dev portaudio19-dev libsndf
``` ```
// 克隆项目到本地 https or ssh // 克隆项目到本地 https or ssh
git clone http://43.132.157.186:3000/gaohz/TakwayBoard.git git clone http://43.132.157.186:3000/gaohz/TakwayBoard.git
cd TakwayBoard cd TakwayBoard && git checkout release/v0.9.1
sudo pip install -v -e . sudo pip install -v -e .
``` ```
@ -55,3 +55,4 @@ sudo python3 setup.py install
``` ```
sudo python3 ws_client.py sudo python3 ws_client.py
``` ```

View File

@ -292,7 +292,7 @@ class HDRecorder(BaseRecorder):
if board == 'v329': if board == 'v329':
self.hardware = V329(hd_trigger, hd_detect_threshold) self.hardware = V329(hd_trigger, hd_detect_threshold)
elif board == 'orangepi': elif board == 'orangepi':
self.hardware = OrangePi(hd_trigger, hd_detect_threshold) self.hardware = OrangePi(hd_trigger, hd_detect_threshold, enable_start_light=True)
print(f"Using {hd_trigger} as hardware trigger.") print(f"Using {hd_trigger} as hardware trigger.")
def wait_for_hardware_pressed(self): def wait_for_hardware_pressed(self):

View File

@ -25,8 +25,9 @@ except:
''' '''
class OrangePi(BaseHardware): class OrangePi(BaseHardware):
def __init__(self, hd_trigger='button', hd_detect_threshold=50): def __init__(self, hd_trigger='button', hd_detect_threshold=50, enable_start_light=False):
super().__init__(hd_trigger, hd_detect_threshold) super().__init__(hd_trigger, hd_detect_threshold)
self.enable_start_light = enable_start_light
self.LED_PIN_red = 0 self.LED_PIN_red = 0
self.LED_PIN_blue = 1 self.LED_PIN_blue = 1
@ -68,7 +69,8 @@ class OrangePi(BaseHardware):
last_status_1 = False last_status_1 = False
press_time_1 = None press_time_1 = None
self.start_status_light() if self.enable_start_light:
self.start_status_light()
while True: while True:
button_status_1 = True if wiringpi.digitalRead(self.BUTTON_PIN_1) == 0 else False button_status_1 = True if wiringpi.digitalRead(self.BUTTON_PIN_1) == 0 else False
# print(f"{datetime.now()}: BUTTON_PIN_1: {wiringpi.digitalRead(self.BUTTON_PIN_1)}") # print(f"{datetime.now()}: BUTTON_PIN_1: {wiringpi.digitalRead(self.BUTTON_PIN_1)}")

View File

@ -6,81 +6,42 @@ import platform
if __name__ == '__main__': if __name__ == '__main__':
server_url = 'ws://222.195.90.129:8001/api/chat/streaming/temporary' server_url = 'ws://43.132.157.186:8002/api/chat/streaming/temporary'
# session_id = 'de9dc06c-2d74-42f8-9c11-9797f9fe0d01' # 麓旬
# session_id = '3f7c2d8f-dc8a-4f1b-9fe0-6bf56c759a41' # 砚文
# session_id = '1fd56ce7-f21e-4eb4-8dc8-3a17960ae328' # 越哥
# session_id = 'bfcc4bbc-ac94-4604-8fd7-50545b8c6a5f' # 楼总
# session_id = '469f4a99-12a5-45a6-bc91-353df07423b6' # 鸿志
# session_id = '9ad8f855-f87c-41c8-a1f3-12e39d013c8c' # 1 积木 刚木 # session_id = 'ef3fd24a-86d9-47c5-94a9-574628ea5a43' # toy1
# session_id = '13e14fd9-a212-4cf1-a09b-5890344c769c' # 2 # session_id = '984651b2-828e-41b7-8a5a-b3ade108dfae' # toy2
# session_id = 'e6e76e50-cb4c-4fe7-8660-8278e712c49b' # 3 # session_id = 'd1427250-adb2-40d6-b41a-0ffcb029a8f8' # toy3
# session_id = '6cbbfa55-58e3-437a-94c4-65eee1fa88a6' # 4 # session_id = '08312487-8751-417e-a89b-2d55558c485c' # toy4
# session_id = 'c14cfd9f-3609-46f9-90aa-ba5a80b65015' # 5 # session_id = '4c75a357-d728-47db-93d3-f1587b180e86' # toy5
# session_id = '33053669-2f6b-442a-8658-b342552b3484' # toy6
excute_args = {} excute_args = {}
# excute_args = {'enable': True}
system = platform.system() system = platform.system()
if system == 'Windows': if system == 'Windows':
print("WebSocketClinet runs on Windows system.") print("WebSocketClinet runs on Windows system.")
board = None board = None
elif system == 'Linux': elif system == 'Linux':
# board = 'v329'
board = 'orangepi' board = 'orangepi'
# ACCESS_KEY = 'neOpatzY/mTzSyxdHs+ajNfpY/7SX1WrlqP/D6+5Km8THUxfZdcauQ==' # luxun # ACCESS_KEY = 'hqNqw85hkJRXVjEevwpkreB8n8so3w9JPQ27qnCR5qTH8a3+XnkZTA==' # gaohz
# ACCESS_KEY = 'KwdWw3V5X9Dz0c9x+5HmGAMi7GbW0kvnaGOAPloIAYwhp06jNt5baw==' # yuyue
# ACCESS_KEY = 'GPFKn+Z9LHGh8yZNfWkLUYRixnrsyY+5w8KN3rpl6sw+Bi7XIqbgTw==' # gaohz (hzgao2000@gmail.com)
# ACCESS_KEY = 'Zo6Vx8YElrjMuA30K9yWMZvD06gcgOfyTi4rC6PPoqWL9mkhA/N/Lg==' # loujc
# ACCESS_KEY = 'Ce5DkiDBQ9B7QNhebpQJyw/f3nhlqO5960yDUfkNAcl9gSj7RzIt6w==' # jinzc
mircophone_device = None mircophone_device = None
speaker_device = None speaker_device = None
keywords = ['芭比']
keyword_paths = None
model_path = None
#
keyword_paths = ["models/芭比_zh_raspberry-pi_v3_0_0/芭比_zh_raspberry-pi_v3_0_0.ppn"]
model_path = "models/porcupine_params_zh.pv"
if board == 'v329': hd_trigger = 'button'
import gpiod as gpio
keywords = ['hey google', 'ok google'] mircophone_device = 2
keyword_paths = None speaker_device = 2
model_path = None
keywords = ['可莉可莉']
keyword_paths = [r"picovoice_models/可莉可莉_zh_raspberry-pi_v3_0_0.ppn"]
model_path = r"picovoice_models/porcupine_params_zh.pv"
hd_trigger = 'button'
player = 'maixsense'
elif board == 'orangepi':
# keywords = ['hey google']
keywords = ['哔卡', '刚木'] # '芭比', , '星云'
keyword_paths = None
model_path = None
#
keyword_paths = ['models/哔卡_zh_raspberry-pi_v3_0_0/哔卡_zh_raspberry-pi_v3_0_0.ppn', 'models/刚木_zh_raspberry-pi_v3_0_0/刚木_zh_raspberry-pi_v3_0_0.ppn']
# "models/芭比_zh_raspberry-pi_v3_0_0/芭比_zh_raspberry-pi_v3_0_0.ppn",
# , 'models/星云_zh_raspberry-pi_v3_0_0/星云_zh_raspberry-pi_v3_0_0.ppn'
model_path = "models/porcupine_params_zh.pv"
hd_trigger = 'button'
mircophone_device = 2
speaker_device = 2
else:
keywords = ['hey google', 'ok google']
keyword_paths = None
model_path = None
hd_trigger = 'keyboard'
player = 'opencv'
import argparse import argparse
@ -123,7 +84,7 @@ if __name__ == '__main__':
parser.add_argument('--IN_CHANNELS', type=int, default=1, help='Audio channels') parser.add_argument('--IN_CHANNELS', type=int, default=1, help='Audio channels')
parser.add_argument('--IN_filename', type=str, default=None, help='Audio file name') parser.add_argument('--IN_filename', type=str, default=None, help='Audio file name')
parser.add_argument('--IN_frames_per_buffer', type=int, default=512, help='Frames per buffer') parser.add_argument('--IN_frames_per_buffer', type=int, default=512, help='Frames per buffer')
parser.add_argument('--min_stream_record_time', type=float, default=0.5, help='Min stream record time, sec') parser.add_argument('--min_stream_record_time', type=float, default=0.3, help='Min stream record time, sec')
parser.add_argument('--max_slience_time', type=int, default=10, help='Max slient time when recording, sec') parser.add_argument('--max_slience_time', type=int, default=10, help='Max slient time when recording, sec')
parser.add_argument('--min_act_time', type=float, default=0.3, help='Min inactive time, sec') # 等待多少秒沉默就发送音频 parser.add_argument('--min_act_time', type=float, default=0.3, help='Min inactive time, sec') # 等待多少秒沉默就发送音频
parser.add_argument('--mircophone_device', type=int, default=mircophone_device, help='Microphone device index') parser.add_argument('--mircophone_device', type=int, default=mircophone_device, help='Microphone device index')