Whisper AI Batch Transcribe #954
Replies: 1 comment 3 replies
-
import whisper Load the speech recognition modelmodel = whisper.load_model("medium.en") Read all MP3 files in the target directorymp3_files = [f for f in os.listdir("/content/drive/MyDrive/FileFolder") if f.endswith(".mp3")] Create a Google Drive API clientauth.authenticate_user() Define a function to upload a file to Google Drivedef upload_to_drive(file_path, file_name): Save the speech-to-text result as a local file and upload it to Google Drivefor i, file in enumerate(mp3_files): This is another one. (Cannot use) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I hope to transcribe my MP3 files in a folder and save the transcripts on Google Drive in Google Colab. However, I noticed that the whisper AI currently does not have the input command line and there seem to be some small issues. As I am not familiar with the code at all, I would like to request help from someone who is knowledgeable. (I know there's some discussion about batch transcribe, but it looks like difficult to set up.) Thank you in advance.
!pip install git+https://github.com/openai/whisper.git
!sudo apt update && sudo apt install ffmpeg
import os
mp3_dir = "/content/drive/MyDrive/FileFolderName"
transcripts_dir = os.path.join(mp3_dir, "Transcribed")
if not os.path.exists(transcripts_dir):
os.makedirs(transcripts_dir)
mp3_files = [f for f in os.listdir(mp3_dir) if f.endswith(".mp3")]
for mp3 in mp3_files:
input_path = os.path.join(mp3_dir, mp3)
output_path = os.path.join(transcripts_dir, f"{mp3}.txt")
!whisper "[]" --model medium.en --input "{input_path}" --output_dir "{transcripts_dir}"
Beta Was this translation helpful? Give feedback.
All reactions