def main(args): # ------------------------------------------------------------------------ # Initialise the Connect SDK. # ------------------------------------------------------------------------ sdk = ChirpConnect() print(sdk.audio.query_devices()) print(str(sdk)) sdk.audio.output_device = args.o if args.network_config: sdk.set_config_from_network() if sdk.protocol_name != '16khz-mono': raise RuntimeError('Must use the 16khz-mono protocol ' + 'to be compatible with other Chirp Messenger apps.') # ------------------------------------------------------------------------ # Parse unicode and send as a chirp payload # ------------------------------------------------------------------------ message = args.message.encode('utf-8') payload = sdk.new_payload(message) sdk.volume = args.volume sdk.set_callbacks(Callbacks()) sdk.start() sdk.send(payload) try: # Process audio streams while True: time.sleep(0.1) except KeyboardInterrupt: print('Exiting') sdk.stop() sdk.close()
def main(input_device): # Initialise Connect SDK sdk = ChirpConnect() print(str(sdk)) print(sdk.audio.query_devices()) if sdk.protocol_name != 'standard': raise RuntimeError('Must use the standard protocol ' + 'to be compatible with other Chirp Messenger apps.') # Configure audio sdk.audio.frame_size = 4096 sdk.audio.input_device = input_device # Set callbacks and start SDK sdk.set_callbacks(Callbacks()) sdk.start(send=False, receive=True) try: # Process audio streams while True: time.sleep(1) except KeyboardInterrupt: print('Exiting') sdk.stop() sdk.close()
def main(app_key, app_secret, app_config, input_device, output_device, block_size, sample_rate): # Initialise ConnectSDK sdk = ChirpConnect(app_key, app_secret, app_config) print(str(sdk)) print('Protocol: {protocol} [v{version}]'.format( protocol=sdk.protocol_name, version=sdk.protocol_version)) print(sdk.audio.query_devices()) # Configure audio sdk.audio.input_device = input_device sdk.audio.output_device = output_device sdk.audio.block_size = block_size sdk.input_sample_rate = sample_rate sdk.output_sample_rate = sample_rate # Set callback functions sdk.set_callbacks(Callbacks()) # Generate random payload and send payload = sdk.random_payload() sdk.start(send=True, receive=True) sdk.send(payload) try: # Process audio streams while True: time.sleep(0.1) sys.stdout.write('.') sys.stdout.flush() except KeyboardInterrupt: print('Exiting') sdk.stop() sdk.close()