Text-to-Audio
Audiocraft
English
audiogen
styletts2
shift-tts
sound
audio-generation
text-to-speech
mimic3
Instructions to use dkounadis/artificial-styletts2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Audiocraft
How to use dkounadis/artificial-styletts2 with Audiocraft:
from audiocraft.models import AudioGen model = AudioGen.get_pretrained("dkounadis/artificial-styletts2") model.set_generation_params(duration=5) # generate 5 seconds. descriptions = ['dog barking', 'sirene of an emergency vehicle', 'footsteps in a corridor'] wav = model.generate(descriptions) # generates 3 samples. - Notebooks
- Google Colab
- Kaggle
| # Asks for txt input, creates TTS and sound via AudioGen, plays it back | |
| # Need to have paplay installed on client - live_demo.py | |
| import os | |
| import requests | |
| import subprocess | |
| from types import SimpleNamespace | |
| def send_to_server(args): | |
| url = "http://192.168.88.209:5000" | |
| payload = { | |
| 'text': args.text, | |
| 'voice': args.voice, | |
| 'soundscape': args.soundscape, | |
| 'affective': True, | |
| 'image': None, | |
| 'video': None, | |
| 'native': None, | |
| } | |
| return requests.post(url, data=payload, files=[(args.text, open('_tmp.txt', 'rb'))]) # NONEs do not arrive to servers dict | |
| args = SimpleNamespace() | |
| args.voice = 'en_US/m-ailabs_low#judy_bieber' | |
| os.system('cls' if os.name == 'nt' else 'clear') | |
| while True: | |
| _str = input("\n\n\n\nDescribe Any Sound: \n\n\n\n") | |
| args.soundscape = _str | |
| _str += 'A quick brown fox jumps over the lazy dog. Sweet dreams are made of this, I traveled the world and the seven seas.' | |
| args.text = '_tmp.txt' # input -> .txt (implementation thought for audiobooks in API) | |
| with open(args.text, 'w') as f: | |
| f.write(_str) | |
| if len(_str) >= 4: | |
| response = send_to_server(args) | |
| out_file = '_gen_.wav'#+ response.headers['suffix-file-type'].split('.')[-1] | |
| with open(out_file, 'wb') as f: | |
| f.write(response.content) | |
| subprocess.run(["paplay", out_file]) | |
| else: | |
| print(f'__\n{_str}\n') | |