@@ -64,8 +64,12 @@ def run():
6464 type = str ,
6565 help = "Path to an audio file | 'microphone' | 'microphone:<DEVICE_ID>'" ,
6666 )
67- parser .add_argument ("--host" , required = True , type = str , help = "Server host" )
68- parser .add_argument ("--port" , required = True , type = int , help = "Server port" )
67+ parser .add_argument (
68+ "--host" , default = "0.0.0.0" , type = str , help = "Server host. Defaults to 0.0.0.0"
69+ )
70+ parser .add_argument (
71+ "--port" , default = 7007 , type = int , help = "Server port. Defaults to 7007"
72+ )
6973 parser .add_argument (
7074 "--step" , default = 0.5 , type = float , help = f"{ argdoc .STEP } . Defaults to 0.5"
7175 )
@@ -93,7 +97,7 @@ def run():
9397
9498 # Wait for READY signal from server
9599 print ("Waiting for server to be ready..." , end = "" , flush = True )
96- while True :
100+ while not stop_event . is_set () :
97101 try :
98102 message = ws .recv ()
99103 if message .strip () == "READY" :
@@ -113,10 +117,19 @@ def run():
113117 sender .start ()
114118 receiver .start ()
115119
120+ try :
121+ # Wait for threads to complete or for keyboard interrupt
122+ sender .join ()
123+ receiver .join ()
124+ except KeyboardInterrupt :
125+ print ("\n Shutting down..." )
126+ stop_event .set ()
127+
116128 except Exception as e :
117129 print (f"Error: { e } " )
118- stop_event . set ()
130+
119131 finally :
132+ stop_event .set ()
120133 try :
121134 ws .close ()
122135 except :
0 commit comments