D
Deleted member 2311908
Guest
I use OBS Studio to generate audio and edit trailers, and this little Python script has become a really handy part of my workflow. It takes a Markdown transcript file, turns it into speech, and outputs a WAV file that I can plug straight into OBS Studio.
Posting it here in case it helps friends build a simple voice workflow for trailers, previews, or narrated content.
Posting it here in case it helps friends build a simple voice workflow for trailers, previews, or narrated content.
Code:
from kokoro import KPipeline
import soundfile as sf
TRANSCRIPT = "transcript.md"
OUT_WAV = "output.wav"
print("Loading Kokoro pipeline...")
pipeline = KPipeline(lang_code='a') # 'a' = American English
text = open(TRANSCRIPT).read().strip()
print("Generating speech...")
generator = pipeline(text, voice='af_heart')
audio_chunks = []
for i, (gs, ps, audio) in enumerate(generator):
audio_chunks.append(audio)
# Concatenate chunks
import numpy as np
full_audio = np.concatenate(audio_chunks)
sf.write(OUT_WAV, full_audio, 24000)
print("Done →", OUT_WAV)