mirror of
https://github.com/sortedcord/kokoro-wayland.git
synced 2026-03-07 23:54:08 +05:30
Initial Upload
This commit is contained in:
24
narrate.py
Normal file
24
narrate.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import sounddevice as sd
|
||||
from kokoro import KPipeline
|
||||
import torch
|
||||
|
||||
# Check if we are actually using your RTX 3050
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
print(f"Using device: {device}")
|
||||
|
||||
# Initialize pipeline with the specific Python 3.12 environment
|
||||
pipeline = KPipeline(lang_code="a", device=device)
|
||||
|
||||
text = """
|
||||
The RTX 3050 is now narrating this documentation.
|
||||
Using uv and Python 3.12 ensures that we avoid the build errors
|
||||
commonly found on Arch Linux's bleeding-edge Python 3.14.
|
||||
"""
|
||||
|
||||
# Generating audio
|
||||
generator = pipeline(text, voice="af_heart", speed=1.1)
|
||||
|
||||
for i, (gs, ps, audio) in enumerate(generator):
|
||||
print(f"Playing chunk {i}...")
|
||||
sd.play(audio, samplerate=24000)
|
||||
sd.wait()
|
||||
Reference in New Issue
Block a user