|  | @@ -7,31 +7,60 @@ def initialize():
 | 
											
												
													
														|  |      if not success:
 |  |      if not success:
 | 
											
												
													
														|  |          print("Warning: Dictionary loading failed. Proceeding with default dictionary.")
 |  |          print("Warning: Dictionary loading failed. Proceeding with default dictionary.")
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  def process_audio_file(audio_file):
 |  |  def process_audio_file(audio_file):
 | 
											
												
													
														|  |      try:
 |  |      try:
 | 
											
												
													
														|  | -        raw_transcript, corrected_transcript = process_audio(audio_file)
 |  | 
 | 
											
												
													
														|  | -        if raw_transcript and corrected_transcript:
 |  | 
 | 
											
												
													
														|  | -            return corrected_transcript
 |  | 
 | 
											
												
													
														|  | 
 |  | +        result = process_audio(audio_file)
 | 
											
												
													
														|  | 
 |  | +        if isinstance(result, tuple) and len(result) == 2:
 | 
											
												
													
														|  | 
 |  | +            return result
 | 
											
												
													
														|  |          else:
 |  |          else:
 | 
											
												
													
														|  | -            return None
 |  | 
 | 
											
												
													
														|  | 
 |  | +            print("Unexpected result from process_audio")
 | 
											
												
													
														|  | 
 |  | +            return None, None
 | 
											
												
													
														|  |      except Exception as e:
 |  |      except Exception as e:
 | 
											
												
													
														|  |          print(f"Error processing audio: {str(e)}")
 |  |          print(f"Error processing audio: {str(e)}")
 | 
											
												
													
														|  | -        return None
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +        return None, None
 | 
											
												
													
														|  | 
 |  | +    
 | 
											
												
													
														|  | 
 |  | +# 加入檢查user是否詢問特定問題
 | 
											
												
													
														|  |  def main(audio_file_path):
 |  |  def main(audio_file_path):
 | 
											
												
													
														|  |      initialize()
 |  |      initialize()
 | 
											
												
													
														|  |      try:
 |  |      try:
 | 
											
												
													
														|  |          with open(audio_file_path, "rb") as audio_file:
 |  |          with open(audio_file_path, "rb") as audio_file:
 | 
											
												
													
														|  | -            result = process_audio_file(audio_file)
 |  | 
 | 
											
												
													
														|  | 
 |  | +            raw_transcript, corrected_transcript = process_audio_file(audio_file)
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  | -        if result:
 |  | 
 | 
											
												
													
														|  | -            print(result)
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if raw_transcript and corrected_transcript:
 | 
											
												
													
														|  | 
 |  | +            print(f"Raw transcript: {raw_transcript}")
 | 
											
												
													
														|  | 
 |  | +            print(f"Corrected transcript: {corrected_transcript}")
 | 
											
												
													
														|  | 
 |  | +            
 | 
											
												
													
														|  | 
 |  | +            if "我要看孫" in raw_transcript:
 | 
											
												
													
														|  | 
 |  | +                print("找到 我要看孫子!連結至cache")
 | 
											
												
													
														|  | 
 |  | +            else:
 | 
											
												
													
														|  | 
 |  | +                print(corrected_transcript)
 | 
											
												
													
														|  |          else:
 |  |          else:
 | 
											
												
													
														|  |              print("Audio processing failed.")
 |  |              print("Audio processing failed.")
 | 
											
												
													
														|  |      except FileNotFoundError:
 |  |      except FileNotFoundError:
 | 
											
												
													
														|  |          print(f"Error: The file '{audio_file_path}' was not found.")
 |  |          print(f"Error: The file '{audio_file_path}' was not found.")
 | 
											
												
													
														|  |      except Exception as e:
 |  |      except Exception as e:
 | 
											
												
													
														|  |          print(f"An unexpected error occurred: {str(e)}")
 |  |          print(f"An unexpected error occurred: {str(e)}")
 | 
											
												
													
														|  | 
 |  | +        import traceback
 | 
											
												
													
														|  | 
 |  | +        traceback.print_exc()
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +## 原本的main
 | 
											
												
													
														|  | 
 |  | +# def main(audio_file_path):
 | 
											
												
													
														|  | 
 |  | +#     initialize()
 | 
											
												
													
														|  | 
 |  | +#     try:
 | 
											
												
													
														|  | 
 |  | +#         with open(audio_file_path, "rb") as audio_file:
 | 
											
												
													
														|  | 
 |  | +#             result = process_audio_file(audio_file)
 | 
											
												
													
														|  | 
 |  | +        
 | 
											
												
													
														|  | 
 |  | +#         if result:
 | 
											
												
													
														|  | 
 |  | +#             print(result)
 | 
											
												
													
														|  | 
 |  | +#         else:
 | 
											
												
													
														|  | 
 |  | +#             print("Audio processing failed.")
 | 
											
												
													
														|  | 
 |  | +#     except FileNotFoundError:
 | 
											
												
													
														|  | 
 |  | +#         print(f"Error: The file '{audio_file_path}' was not found.")
 | 
											
												
													
														|  | 
 |  | +#     except Exception as e:
 | 
											
												
													
														|  | 
 |  | +#         print(f"An unexpected error occurred: {str(e)}")
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  if __name__ == "__main__":
 |  |  if __name__ == "__main__":
 | 
											
												
													
														|  |      if len(sys.argv) != 2:
 |  |      if len(sys.argv) != 2:
 |