import sys from api.openai_scripts_tai_gi.dictionary_loader import load_word_database_dictionary_from_supabase from api.openai_scripts_tai_gi.audio_processing import process_audio def initialize(): word_database_success = load_word_database_dictionary_from_supabase() if not word_database_success: print("Warning: Word Database Dictionary loading failed. Proceeding with default dictionary.") def process_audio_file(audio_file): try: result = process_audio(audio_file) if isinstance(result, tuple) and len(result) == 2: return result else: print("Unexpected result from process_audio") return None, None except Exception as e: print(f"Error processing audio: {str(e)}") return None, None # 加入檢查user是否詢問特定問題 def main(audio_file): initialize() try: raw_transcript, corrected_transcript = process_audio_file(audio_file) return raw_transcript, corrected_transcript except FileNotFoundError: print(f"Error: The file was not found.") return None, None except Exception as e: print(f"An unexpected error occurred: {str(e)}") import traceback traceback.print_exc() return None, None if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python script_name.py ") sys.exit(1) audio_file_path = sys.argv[1] main(audio_file_path)