File size: 2,414 Bytes
10ea2f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
393129e
10ea2f8
 
 
 
 
 
 
 
 
 
 
 
 
 
393129e
10ea2f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
Chiluka TTS - PyTorch Hub Example

Load the model using torch.hub.load() - no pip install needed,
just PyTorch and a GitHub repo.

Requirements:
    pip install torch torchaudio
    sudo apt-get install espeak-ng

Usage:
    python torchhub_example.py --reference path/to/reference.wav
    python torchhub_example.py --reference ref.wav --variant telugu --language te
"""

import argparse
import torch


def main():
    parser = argparse.ArgumentParser(description="Chiluka TTS - PyTorch Hub Example")
    parser.add_argument("--reference", type=str, required=True, help="Path to reference audio file")
    parser.add_argument("--variant", type=str, default="default", choices=["default", "telugu", "hindi_english"],
                        help="Model variant (default, telugu, hindi_english)")
    parser.add_argument("--text", type=str, default=None, help="Text to synthesize")
    parser.add_argument("--language", type=str, default=None, help="Language code (en-us, hi, te)")
    parser.add_argument("--output", type=str, default="output_torchhub.wav", help="Output wav file path")
    args = parser.parse_args()

    # Set defaults
    if args.text is None:
        if args.variant == "telugu":
            args.text = "నమస్కారం, నేను చిలుక మాట్లాడుతున్నాను"
        else:
            args.text = "Hello, I am Chiluka, a text to speech system."

    if args.language is None:
        if args.variant == "telugu":
            args.language = "te"
        else:
            args.language = "en-us"

    # Load via torch.hub
    # Available entry points:
    #   'chiluka'              - Hindi-English model (default)
    #   'chiluka_telugu'       - Telugu model
    #   'chiluka_hindi_english' - Hindi-English model (explicit)
    print(f"Loading model via torch.hub (variant: {args.variant})...")

    if args.variant == "telugu":
        tts = torch.hub.load('Seemanth/chiluka', 'chiluka_telugu')
    else:
        tts = torch.hub.load('Seemanth/chiluka', 'chiluka')

    # Synthesize
    print(f"Synthesizing: '{args.text}'")
    print(f"Language: {args.language}")
    wav = tts.synthesize(
        text=args.text,
        reference_audio=args.reference,
        language=args.language,
    )

    # Save
    tts.save_wav(wav, args.output)
    print(f"Duration: {len(wav) / 24000:.2f} seconds")


if __name__ == "__main__":
    main()