I'm afraid I don't understand the text about moving parts of the script in collab.
The script is divided into
#@markdown **Run Whisper**
# @markdown Required settings:
# Generate VAD timestamps
# Add a bit of padding, and remove small gaps
# If breaks are longer than chunk_threshold seconds, split into a new audio file
# This'll effectively turn long transcriptions into many shorter ones
# Merge speech chunks
# Convert timestamps to seconds
# Run Whisper on each audio chunk
Lots of small edits to the above
# DeepL translation
# Write SRT file
I don't understand which 'block' to move and where.
Is it everything in the first block like this:
if "http://" in audio_path or "https://" in audio_path:
print("Downloading audio...")
urllib.request.urlretrieve(audio_path, "input_file")
audio_path = "input_file"
else:
if not os.path.exists(audio_path):
try:
audio_path = uploaded_file
if not os.path.exists(audio_path):
raise ValueError("Input audio not found. Is your audio_path correct?")
except NameError:
raise ValueError("Input audio not found. Did you upload a file?")
out_path = os.path.splitext(audio_path)[0] + ".srt"
out_path_pre = os.path.splitext(audio_path)[0] + "_Untranslated.srt"
if source_separation:
print("Separating vocals...")
!ffprobe -i "{audio_path}" -show_entries format=duration -v quiet -of csv="p=0" > input_length
with open("input_length") as f:
input_length = int(float(f.read())) + 1
!spleeter separate -d {input_length} -p spleeter:2stems -o output "{audio_path}"
spleeter_dir = os.path.basename(os.path.splitext(audio_path)[0])
audio_path = "output/" + spleeter_dir + "/vocals.wav"
print("Encoding audio...")
if not os.path.exists("vad_chunks"):
os.mkdir("vad_chunks")
ffmpeg.input(audio_path).output(
"vad_chunks/silero_temp.wav",
ar="16000",
ac="1",
acodec="pcm_s16le",
map_metadata="-1",
fflags="+bitexact",
).overwrite_output().run(quiet=True)
print("Running VAD...")
model, utils = torch.hub.load(
repo_or_dir="snakers4/silero-vad:v4.0", model="silero_vad", onnx=False
)
(get_speech_timestamps, save_audio, read_audio, VADIterator, collect_chunks) = utils
and move it to under
# Write SRT file
??
The script is divided into
#@markdown **Run Whisper**
# @markdown Required settings:
# Generate VAD timestamps
# Add a bit of padding, and remove small gaps
# If breaks are longer than chunk_threshold seconds, split into a new audio file
# This'll effectively turn long transcriptions into many shorter ones
# Merge speech chunks
# Convert timestamps to seconds
# Run Whisper on each audio chunk
Lots of small edits to the above
# DeepL translation
# Write SRT file
I don't understand which 'block' to move and where.
Is it everything in the first block like this:
if "http://" in audio_path or "https://" in audio_path:
print("Downloading audio...")
urllib.request.urlretrieve(audio_path, "input_file")
audio_path = "input_file"
else:
if not os.path.exists(audio_path):
try:
audio_path = uploaded_file
if not os.path.exists(audio_path):
raise ValueError("Input audio not found. Is your audio_path correct?")
except NameError:
raise ValueError("Input audio not found. Did you upload a file?")
out_path = os.path.splitext(audio_path)[0] + ".srt"
out_path_pre = os.path.splitext(audio_path)[0] + "_Untranslated.srt"
if source_separation:
print("Separating vocals...")
!ffprobe -i "{audio_path}" -show_entries format=duration -v quiet -of csv="p=0" > input_length
with open("input_length") as f:
input_length = int(float(f.read())) + 1
!spleeter separate -d {input_length} -p spleeter:2stems -o output "{audio_path}"
spleeter_dir = os.path.basename(os.path.splitext(audio_path)[0])
audio_path = "output/" + spleeter_dir + "/vocals.wav"
print("Encoding audio...")
if not os.path.exists("vad_chunks"):
os.mkdir("vad_chunks")
ffmpeg.input(audio_path).output(
"vad_chunks/silero_temp.wav",
ar="16000",
ac="1",
acodec="pcm_s16le",
map_metadata="-1",
fflags="+bitexact",
).overwrite_output().run(quiet=True)
print("Running VAD...")
model, utils = torch.hub.load(
repo_or_dir="snakers4/silero-vad:v4.0", model="silero_vad", onnx=False
)
(get_speech_timestamps, save_audio, read_audio, VADIterator, collect_chunks) = utils
and move it to under
# Write SRT file
??