This is a real quick post to point out a problem that very likely has plagued you in the past: Namely, wasting time On tutorials that don’t work
This can be very frustrating as a beginner because you’re assuming the problem is with you. However I’m here to assure you that quite often it’s laziness of the people posting the tutorials.
Let me show you this code from over at Medium.com
This is code for installing Pyannote and Whisper
from subprocess import CalledProcessError, run
from pyannote.audio import Pipeline
import os
def split_audio(input_file, output_file, start, end):
length = end - start
cmd = ["ffmpeg", "-ss", str(start), "-i", input_file, "-t", str(length), "-vn", "-acodec", "pcm_s16le", "-ar", "48000", "-ac", "1", output_file]
try:
run(cmd, capture_output=True, check=True).stdout
except CalledProcessError as e:
raise RuntimeError(f"FFMPEG error {str(e)}")
pipeline = Pipeline.from_pretrained(
"pyannote/speaker-diarization@2.1",
use_auth_token="<HF_ACCESS_TOKEN_HERE>"
)
input_wav = "test.wav"
output_dir = "output"
count = 10001
# inference
diarization = pipeline(input_wav)
for turn, _, speaker in diarization.itertracks(yield_label=True):
print(f"start={turn.start}s stop={turn.end}s speaker_{speaker}")
speaker_dir = f"{output_dir}/speaker_{speaker}/"
if not os.path.isdir(speaker_dir):
os.mkdir(speaker_dir)
filename = os.path.join(speaker_dir, f"interview-{count}.wav")
split_audio(input_wav, filename, turn.start, turn.end)
count += 1
At first glance, your thought is great! Let’s just plug this in and run it But you soon come to the problem that it doesn’t work. Depending on your time you have and your experience level,. Then end up spending a bunch of time on the Internet trying to figure what’s going on
However, let’s take a quick look and it’s not hard to figure out that this code is crap. The main thing being and I was a variable called “input_file”. If you look closely you’ll realize that it is not defined. In fact, “input_wav” is used. This is an error
Now, It’s a fairly easy fix if you know what you’re looking at But let’s talk about why you get crap tutorials.
Answer: It’s a relic of the early days of GPT. The authors of many of the tutorials we’re seeing today are part of what I call the first wave (If you’re reading this, we’re part of the second wave, Congratulations!). One of the relics of the first wave is that they used GPT to write their posts. Many, many of the tutorials you read are hustlers that found they can quickly put up blogs and get paid for them by having GPT ripe for them. Unfortunately, that means there’s errors because GPT is not perfect in coding and particularly not back when many of these tutorials were written.
One of the key things to do is look at the date of when these tutorials are written. You don’t have to throw out the tutorials because there’s incredible learning knowledge in there, but you have to understand that these guys cheated a little bit.What’s the takeaway,? The takeaway is this… Use the resources given you but understand that they are flawed.
LEARN PYTHON — LEARN BASIC PROGRAMMING CONCEPTS — just like Learning an instrument… Music theory never changes regardless of the instrument. Likewise, programming concepts stay the same regardless of the language. To learn python but more than anything you need to learn some basic programming concepts. Once you do that, a lot of these bad tutorials will stop wasting so much of your time.
Leave a Reply