@@ -624,13 +624,12 @@ def main():
624
624
else :
625
625
config_path = os .path .join (os .path .dirname (os .path .realpath (__file__ )), 'config.json' )
626
626
627
+ config = {}
627
628
if os .path .exists (config_path ):
628
- with open (config_path , 'r' ) as fd :
629
+ with open (config_path , 'r' , encoding = 'utf-8' ) as fd :
629
630
config = json .load (fd )
630
631
elif args .config is not None :
631
632
parser .error (f'File { config_path } does not exist' )
632
- else :
633
- config = {}
634
633
635
634
for key in chain (REQUIRED_ARGS , DEFAULT_ARGS ):
636
635
arg = getattr (args , key )
@@ -641,9 +640,9 @@ def main():
641
640
if len (missing ) > 0 :
642
641
parser .error ('the following arguments are required: ' + ', ' .join (missing ))
643
642
644
- for key in DEFAULT_ARGS :
643
+ for key , value in DEFAULT_ARGS . items () :
645
644
if key not in config :
646
- config [key ] = DEFAULT_ARGS [ key ]
645
+ config [key ] = value
647
646
648
647
stop = [False ]
649
648
@@ -676,14 +675,19 @@ def handler(_, __) -> None:
676
675
677
676
print (f"→ Cheetah v{ cheetah .version } " )
678
677
679
- pv_recorder = PvRecorder (frame_length = porcupine .frame_length )
680
- pv_speaker = PvSpeaker (sample_rate = int (orca_connection .recv ()), bits_per_sample = 16 , buffer_size_secs = 1 )
678
+ try :
679
+ pv_recorder = PvRecorder (frame_length = porcupine .frame_length )
680
+ pv_speaker = PvSpeaker (sample_rate = int (orca_connection .recv ()), bits_per_sample = 16 , buffer_size_secs = 1 )
681
681
682
- pllm_info = pllm_connection .recv ()
683
- print (f"→ picoLLM v{ pllm_info ['version' ]} <{ pllm_info ['model' ]} >" )
682
+ pllm_info = pllm_connection .recv ()
683
+ print (f"→ picoLLM v{ pllm_info ['version' ]} <{ pllm_info ['model' ]} >" )
684
684
685
- orca_info = orca_connection .recv ()
686
- print (f"→ Orca v{ orca_info ['version' ]} " )
685
+ orca_info = orca_connection .recv ()
686
+ print (f"→ Orca v{ orca_info ['version' ]} " )
687
+ except EOFError :
688
+ for child in active_children ():
689
+ child .kill ()
690
+ exit (1 )
687
691
688
692
speaker = Speaker (pv_speaker , config )
689
693
synthesizer = Synthesizer (speaker , orca_connection , orca_process , config )
0 commit comments