GoogleCollab Workflow: Video-To-Text mit OpenAI Whisper.
Wandelt automtisch Youtube-Videos in Text
Hallo zusammen, ausnhamsweise mal etwas ausserhalb der nornalen Tradingvideos:
Ein kleiner Workflow, wie ihr ohne Coding-Kenntnisse mit GoogleCollab und OpenAI Whisper Videos/Audios in .txt files verwandelt könnt.
Wir lesen schneller und effizienter als wir etwas hören oder sehen - und ihr kennt bestimmt viele Youtube-Videos wo man das Bild nun wirklich nicht benötigt.. daher nutzen wir das MachineLearning Modell von Whisper um automatisch Audio-Dateien in Text zu transkribieren.
Den benötigten Code für Collab:
1.)
!pip install git+https://github.com/openai/whisper.git
!sudo apt update && sudo apt install ffmpeg
2.)
import os
import whisper
from tqdm import tqdm
# Define the folder where the wav files are located
root_folder = "/content/drive/MyDrive/Whisper/output/"
# Set up Whisper client
print("Loading whisper model...")
model = whisper.load_model("medium")
print("Whisper model complete.")
# Get the number of wav files in the root folder and its sub-folders
print("Getting number of files to transcribe...")
num_files = sum(1 for dirpath, dirnames, filenames in os.walk(root_folder) for filename in filenames if filename.endswith(".mp3"))
print("Number of files: ", num_files)
# Transcribe the wav files and display a progress bar
with tqdm(total=num_files, desc="Transcribing Files") as pbar:
for dirpath, dirnames, filenames in os.walk(root_folder):
for filename in filenames:
if filename.endswith(".mp3"):
filepath = os.path.join(dirpath, filename)
result = model.transcribe(filepath, fp16=False, verbose=True)
transcription = result['text']
# Write transcription to text file
filename_no_ext = os.path.splitext(filename)[0]
with open(os.path.join(dirpath, filename_no_ext + '.txt'), 'w') as f:
f.write(transcription)
pbar.update(1)
Viel Spass, und wie immer: Gerne Kommentieren, liken und abonnieren!
Viele Grüsse, Khan