@@ -64,8 +64,12 @@ def run():
64
64
type = str ,
65
65
help = "Path to an audio file | 'microphone' | 'microphone:<DEVICE_ID>'" ,
66
66
)
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
+ )
69
73
parser .add_argument (
70
74
"--step" , default = 0.5 , type = float , help = f"{ argdoc .STEP } . Defaults to 0.5"
71
75
)
@@ -93,7 +97,7 @@ def run():
93
97
94
98
# Wait for READY signal from server
95
99
print ("Waiting for server to be ready..." , end = "" , flush = True )
96
- while True :
100
+ while not stop_event . is_set () :
97
101
try :
98
102
message = ws .recv ()
99
103
if message .strip () == "READY" :
@@ -113,10 +117,19 @@ def run():
113
117
sender .start ()
114
118
receiver .start ()
115
119
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
+
116
128
except Exception as e :
117
129
print (f"Error: { e } " )
118
- stop_event . set ()
130
+
119
131
finally :
132
+ stop_event .set ()
120
133
try :
121
134
ws .close ()
122
135
except :
0 commit comments