Created
October 15, 2023 10:25
-
-
Save jeanpaul/f08ec605ab43befd5cf24336f45506eb to your computer and use it in GitHub Desktop.
This file contains 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 sys | |
from pathlib import Path | |
import openai | |
from pydub import AudioSegment | |
podcast_file = sys.argv[1] | |
openai.api_key_path = Path("~/.openai-api-key.txt").expanduser() | |
podcast = AudioSegment.from_mp3(podcast_file) | |
ten_minutes = 10 * 60 * 1000 | |
first_10_minutes = podcast[:ten_minutes] | |
for segment in podcast[::ten_minutes]: | |
transcript = openai.Audio.transcribe( | |
"whisper-1", | |
segment.export("/tmp/segment.mp3", format="mp3") | |
) | |
print(transcript.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment