#๐ Was recommended Kokoro TTS, lack of much documentation has me a little flustered.
6 messages ยท Page 1 of 1 (latest)
Hey @ionic sinew!
Please edit your message to use a code block
Add a py after the three backticks.
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
@ionic sinew
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
from kokoro import KPipeline, KModel
import torch
from scipy.io import wavfile
def save_audio(audio: torch.Tensor, filename: str):
"""Helper function to save audio tensor as WAV file"""
# Ensure audio is on CPU and in the right format
audio_cpu = audio.cpu().numpy()
# Save using scipy.io.wavfile
wavfile.write(
filename,
24000, # Kokoro uses 24kHz sample rate
audio_cpu
)
print(f"Audio saved as '{filename}'")
def main():
# Initialize pipeline with American English
pipeline = KPipeline(lang_code='a')
# Example 2: Using generate_from_tokens with pre-processed tokens
# get the tokens through G2P or any other method
text = "How are you today? I am doing reasonably well, thank you for asking"
_, tokens = pipeline.g2p(text)
# Then generate from tokens
for result in pipeline.generate_from_tokens(
tokens=tokens,
voice="af_bella",
speed=1.0
):
save_audio(result.audio, f'token_output_{hash(result.phonemes)}.wav')
if __name__ == "__main__":
main()
I'm a bit of a complete newbie so things are a little iffy to me to begin with but would I be mistaken if a simple return statement would work on the save_audio variable to use it to convert through RVC/use it for real time TTS in general?
@ionic sinew
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.