@@ -95,15 +95,21 @@ from Simpler_Kokoro import SimplerKokoro
9595# Create an instance
9696sk = SimplerKokoro()
9797
98- # List available voices
98+ # Load the available voices
9999voices = sk.list_voices()
100- print (" Available voices:" , [v[' name' ] for v in voices])
100+
101+ # (optional) Print out the voices
102+ for voice in voices:
103+ print (voice) # Print out the voice object
104+
105+ # Use the first voice as example
106+ selected_voice = voices[0 ]
101107
102108# Generate speech
103109sk.generate(
104- text = " Hello, this is a test of the Simpler Kokoro voice synthesis." ,
105- voice = voices[ 0 ][ ' name' ] , # Make sure to specify the name of the voice
106- output_path = " output.wav"
110+ text = ' Hello, this is a test of the Simpler Kokoro voice synthesis.' , # Text to generate
111+ voice = selected_voice. name, # Grab the name from the selected voice
112+ output_path = ' output.wav' # Select the output path.
107113)
108114```
109115</details >
@@ -112,15 +118,25 @@ sk.generate(
112118<summary ><b >Generate Speech with Subtitles</b ></summary >
113119
114120``` python
121+ from Simpler_Kokoro import SimplerKokoro
122+
123+ # Create an instance
115124sk = SimplerKokoro()
116125
126+ # Load the available voices
127+ voices = sk.list_voices()
128+
129+ # Use the first voice as example
130+ selected_voice = voices[0 ]
131+
132+ # Generate speech
117133sk.generate(
118- text = " Hello, this is a test. This is another sentence. " ,
119- voice = voices[ 0 ][ ' name' ],
120- output_path = " output.wav" ,
121- write_subtitles = True ,
122- subtitles_path = " output .srt" ,
123- subtititles_word_level = True
134+ text = ' Hello, this will generate a subtitles.srt file along with output.wav ' , # Text to generate
135+ voice = selected_voice. name, # Grab the name from the selected voice
136+ output_path = ' output.wav' , # Select the output path
137+ write_subtitles = True , # Enable subtitle generation
138+ subtitles_path = ' subtitles .srt' , # (optional) Specify the subtitle .srt filename
139+ subtitles_word_level = True # (optional) Enable word level timestamps
124140)
125141```
126142</details >
@@ -129,13 +145,23 @@ sk.generate(
129145<summary ><b >Generate Speech with Custom Speed</b ></summary >
130146
131147``` python
148+ from Simpler_Kokoro import SimplerKokoro
149+
150+ # Create an instance
132151sk = SimplerKokoro()
133152
153+ # Load the available voices
154+ voices = sk.list_voices()
155+
156+ # Use the first voice as example
157+ selected_voice = voices[0 ]
158+
159+ # Generate speech
134160sk.generate(
135- text = " This is spoken faster than normal. " ,
136- voice = voices[ 1 ][ ' name' ],
137- output_path = " fast_output .wav" ,
138- speed = 1.5
161+ text = ' Hello, this is a test of the Simpler Kokoro voice synthesis. ' , # Text to generate
162+ voice = selected_voice. name, # Grab the name from the selected voice
163+ output_path = ' output .wav' , # Select the output path
164+ speed = 1.5 # This represents 150% Speed. 1 means 100% and 0.5 means 50%
139165)
140166```
141167</details >
@@ -144,12 +170,22 @@ sk.generate(
144170<summary ><b >Specify a Path to Download Models</b ></summary >
145171
146172``` python
147- sk = SimplerKokoro( models_dir = " Folder-to-put-models-in " ) # Put the models dir here
173+ from Simpler_Kokoro import SimplerKokoro
148174
175+ # Create an instance
176+ sk = SimplerKokoro(models_dir = ' <PATH TO PUT MODELS>' ) # Put in the path where you want the models to be saved here
177+
178+ # Load the available voices
179+ voices = sk.list_voices()
180+
181+ # Use the first voice as example
182+ selected_voice = voices[0 ]
183+
184+ # Generate speech
149185sk.generate(
150- text = " Thats a cool model directory. " ,
151- voice = voices[ 1 ][ ' name' ],
152- output_path = " fast_output .wav" ,
186+ text = ' Select a custom directory for the models! ' , # Text to generate
187+ voice = selected_voice. name, # Grab the name from the selected voice
188+ output_path = ' output .wav' # Select the output path.
153189)
154190```
155191</details >
0 commit comments