def main(radio_idx): radio = Radio(int(radio_idx), mic_threshold=MIC_THRESHOLD, input_rate=INPUT_RATE, input_id=INPUT_ID, output_id=OUTPUT_ID) radio.connect(server=0) radio.start_speaker_stream() while True: radio.stream_mic_segment_to_server()
def main(radio_idx): global radio radio = Radio(int(radio_idx), mic_threshold=MIC_THRESHOLD, input_rate=INPUT_RATE, input_id=INPUT_ID, output_id=OUTPUT_ID) # initialize volume control # volume_thread = Thread(target=volume_main) # volume_thread.start() # # channel_selection_thread = Thread(target=channel_selection) # channel_selection_thread.start() # power button powerButton = Button(POWER_PIN, pull_up=False) # mute button muteButton = Button(MUTE_PIN, pull_up=False) powerButton.when_pressed = switchedOn powerButton.when_released = switchedOff muteButton.when_pressed = unmuteMic muteButton.when_released = muteMic # assign functions for change volume volControlB.when_pressed = volcw volControlA.when_pressed = volccw # assign functions for change channel chnlControlB.when_pressed = chnlcw chnlControlA.when_pressed = chnlccw radio.connect(server=0) radio.start_speaker_stream() #print("play poweron") #radio.play_bilingual_notification(POWERON) while True: radio.stream_mic_segment_to_server() # print("curr", radio.get_current_channel()) # print("new", channel) # print("now", time()) # print("last", lastUpdateTime) if radio.get_current_channel() != channel and time() - lastUpdateTime > 1: # print("changing channel...") radio.change_channel(channel) radio.play_bilingual_notification(CHNLS[channel])