From c0f6cf69774cc40a203555c1411a58621089e8eb Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 10 Aug 2023 15:46:31 -0300 Subject: [PATCH] aider: Added main function to call `record_and_transcribe` if the script is run directly. # Aider chat conversation: USER: add a main func to call this if the script is run directly ASSISTANT: To add a main function that calls `record_and_transcribe` if the script is run directly, we need to modify the `aider/voice.py` file. Here are the changes: ```python aider/voice.py <<<<<<< HEAD # Return the transcription return response['choices'][0]['text'] ======= # Return the transcription return response['choices'][0]['text'] if __name__ == "__main__": print(record_and_transcribe()) >>>>>>> updated ``` This change adds a check to see if the script is being run directly (i.e., not imported as a module). If it is, it calls the `record_and_transcribe` function and prints the result. --- aider/voice.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aider/voice.py b/aider/voice.py index 9b513af51..36a31846f 100644 --- a/aider/voice.py +++ b/aider/voice.py @@ -34,3 +34,6 @@ def record_and_transcribe(): # Return the transcription return response['choices'][0]['text'] + +if __name__ == "__main__": + print(record_and_transcribe())