Last active
October 22, 2023 05:52
-
-
Save shehbajdhillon/100755f9bbf6ecffd41c954684be5ad1 to your computer and use it in GitHub Desktop.
Transcribe Using Whisper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| import openai | |
| openai.api_key = os.getenv("OPENAI_API_KEY") | |
| def transcribe_audio(file_path): | |
| file = open(file_path, "rb") | |
| transcript = openai.Audio.transcribe( | |
| model="whisper-1", | |
| file=file, | |
| response_format="verbose_json" | |
| ) | |
| return transcript | |
| def main(): | |
| file_path = sys.argv[1] | |
| transcript = transcribe_audio(file_path=file_path) | |
| print(transcript) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment