live api
Browse files- live_api.py +3 -5
live_api.py
CHANGED
@@ -6,7 +6,6 @@ import audresample
|
|
6 |
import text_utils
|
7 |
|
8 |
import re
|
9 |
-
import srt
|
10 |
import subprocess
|
11 |
import markdown
|
12 |
import json
|
@@ -14,10 +13,9 @@ from pathlib import Path
|
|
14 |
from types import SimpleNamespace
|
15 |
from flask import Flask, request, send_from_directory
|
16 |
from flask_cors import CORS
|
17 |
-
from audiocraft.
|
18 |
|
19 |
-
sound_generator = AudioGen.
|
20 |
-
sound_generator.set_generation_params(duration=.7)
|
21 |
|
22 |
|
23 |
# ====STYLE VECTOR====
|
@@ -48,7 +46,7 @@ Path(CACHE_DIR).mkdir(parents=True, exist_ok=True)
|
|
48 |
def tts_multi_sentence(scene=None):
|
49 |
if scene is not None and len(scene) >= 4:
|
50 |
print(f'Processing: {scene} ..')
|
51 |
-
x = sound_generator.generate([scene])[0].detach().cpu().numpy()
|
52 |
|
53 |
x /= np.abs(x).max() + 1e-7
|
54 |
# is 16kHz - AUdiogen Fs
|
|
|
6 |
import text_utils
|
7 |
|
8 |
import re
|
|
|
9 |
import subprocess
|
10 |
import markdown
|
11 |
import json
|
|
|
13 |
from types import SimpleNamespace
|
14 |
from flask import Flask, request, send_from_directory
|
15 |
from flask_cors import CORS
|
16 |
+
from audiocraft.builders import AudioGen #, audio_write
|
17 |
|
18 |
+
sound_generator = AudioGen(duration=.74, device='cuda:0').to('cuda:0').eval()
|
|
|
19 |
|
20 |
|
21 |
# ====STYLE VECTOR====
|
|
|
46 |
def tts_multi_sentence(scene=None):
|
47 |
if scene is not None and len(scene) >= 4:
|
48 |
print(f'Processing: {scene} ..')
|
49 |
+
x = sound_generator.generate([scene])[0, :, :].detach().cpu().numpy()
|
50 |
|
51 |
x /= np.abs(x).max() + 1e-7
|
52 |
# is 16kHz - AUdiogen Fs
|