|
|
|
|
|
|
|
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, |
|
'speed': 1.14, |
|
'native': None, |
|
} |
|
|
|
return requests.post(url, data=payload, files=[(args.text, open('_tmp.txt', 'rb'))]) |
|
|
|
|
|
args = SimpleNamespace() |
|
args.voice = 'fr_FR_m-ailabs_bernard' |
|
args.speed = 1.14 |
|
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 |
|
|
|
|
|
if len(_str) < 20: |
|
_str += 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata few silence for audiogen to impress you.' |
|
args.text = '_tmp.txt' |
|
|
|
with open(args.text, 'w') as f: |
|
f.write(_str) |
|
if len(_str) >= 4: |
|
response = send_to_server(args) |
|
out_file = '_gen_.wav' |
|
with open(out_file, 'wb') as f: |
|
f.write(response.content) |
|
subprocess.run(["paplay", out_file]) |
|
else: |
|
print(f'__\n{_str}\n') |
|
|