Add audio saving to speech generation in README
Added audio saving functionality to the speech generation examples.
This commit is contained in:
10
README.md
10
README.md
@@ -45,6 +45,7 @@ lux_tts = LuxTTS('YatharthS/LuxTTS', device='cuda', threads=2) ## change device
|
|||||||
|
|
||||||
#### Simple inference
|
#### Simple inference
|
||||||
```python
|
```python
|
||||||
|
import soundfile as sf
|
||||||
from IPython.display import Audio
|
from IPython.display import Audio
|
||||||
|
|
||||||
text = "Hey, what's up? I'm feeling really great if you ask me honestly!"
|
text = "Hey, what's up? I'm feeling really great if you ask me honestly!"
|
||||||
@@ -58,12 +59,17 @@ encoded_prompt = lux_tts.encode_prompt(prompt_audio, rms=0.01)
|
|||||||
## generate speech
|
## generate speech
|
||||||
final_wav = lux_tts.generate_speech(text, encoded_prompt, num_steps=num_steps)
|
final_wav = lux_tts.generate_speech(text, encoded_prompt, num_steps=num_steps)
|
||||||
|
|
||||||
|
## save audio
|
||||||
|
final_wav = final_wav.numpy().squeeze()
|
||||||
|
sf.write('output.wav', audio_data, 48000)
|
||||||
|
|
||||||
## display speech
|
## display speech
|
||||||
display(Audio(final_wav, rate=48000))
|
display(Audio(final_wav, rate=48000))
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Inference with sampling params:
|
#### Inference with sampling params:
|
||||||
```python
|
```python
|
||||||
|
import soundfile as sf
|
||||||
from IPython.display import Audio
|
from IPython.display import Audio
|
||||||
|
|
||||||
text = "Hey, what's up? I'm feeling really great if you ask me honestly!"
|
text = "Hey, what's up? I'm feeling really great if you ask me honestly!"
|
||||||
@@ -83,6 +89,10 @@ encoded_prompt = lux_tts.encode_prompt(prompt_audio, rms=rms)
|
|||||||
## generate speech
|
## generate speech
|
||||||
final_wav = lux_tts.generate_speech(text, encoded_prompt, num_steps=num_steps, t_shift=t_shift, speed=speed, return_smooth=return_smooth)
|
final_wav = lux_tts.generate_speech(text, encoded_prompt, num_steps=num_steps, t_shift=t_shift, speed=speed, return_smooth=return_smooth)
|
||||||
|
|
||||||
|
## save audio
|
||||||
|
final_wav = final_wav.numpy().squeeze()
|
||||||
|
sf.write('output.wav', audio_data, 48000)
|
||||||
|
|
||||||
## display speech
|
## display speech
|
||||||
display(Audio(final_wav, rate=48000))
|
display(Audio(final_wav, rate=48000))
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user