Spaces:
Running
Running
navalnica
commited on
Commit
Β·
aefca6a
1
Parent(s):
1a79fb2
bugfix
Browse files- src/emotions/generation.py +12 -6
src/emotions/generation.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1 |
-
import openai
|
2 |
import json
|
3 |
-
from requests import HTTPError
|
4 |
from abc import ABC, abstractmethod
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
from .prompts import (
|
7 |
SOUND_EFFECT_GENERATION,
|
8 |
SOUND_EFFECT_GENERATION_WITHOUT_DURATION_PREDICTION,
|
@@ -10,8 +14,6 @@ from .prompts import (
|
|
10 |
TEXT_MODIFICATION_WITH_SSML,
|
11 |
)
|
12 |
from .utils import get_audio_duration
|
13 |
-
from src.config import logger
|
14 |
-
from src.utils import auto_retry
|
15 |
|
16 |
|
17 |
class AbstractEffectGenerator(ABC):
|
@@ -81,7 +83,9 @@ class EffectGenerator(AbstractEffectGenerator):
|
|
81 |
raise RuntimeError(f"Unexpected Error: {e}")
|
82 |
|
83 |
@auto_retry
|
84 |
-
def generate_parameters_for_sound_effect(
|
|
|
|
|
85 |
llm_output = self.generate_text_for_sound_effect(text)
|
86 |
if generated_audio_file is not None:
|
87 |
llm_output["duration_seconds"] = get_audio_duration(generated_audio_file)
|
@@ -161,7 +165,9 @@ class EffectGeneratorAsync(AbstractEffectGenerator):
|
|
161 |
raise RuntimeError(f"Unexpected Error: {e}")
|
162 |
|
163 |
@auto_retry
|
164 |
-
async def generate_parameters_for_sound_effect(
|
|
|
|
|
165 |
llm_output = await self.generate_text_for_sound_effect(text)
|
166 |
if generated_audio_file is not None:
|
167 |
llm_output["duration_seconds"] = get_audio_duration(generated_audio_file)
|
|
|
|
|
1 |
import json
|
|
|
2 |
from abc import ABC, abstractmethod
|
3 |
|
4 |
+
import openai
|
5 |
+
from requests import HTTPError
|
6 |
+
|
7 |
+
from src.config import OPENAI_API_KEY, logger
|
8 |
+
from src.utils import auto_retry
|
9 |
+
|
10 |
from .prompts import (
|
11 |
SOUND_EFFECT_GENERATION,
|
12 |
SOUND_EFFECT_GENERATION_WITHOUT_DURATION_PREDICTION,
|
|
|
14 |
TEXT_MODIFICATION_WITH_SSML,
|
15 |
)
|
16 |
from .utils import get_audio_duration
|
|
|
|
|
17 |
|
18 |
|
19 |
class AbstractEffectGenerator(ABC):
|
|
|
83 |
raise RuntimeError(f"Unexpected Error: {e}")
|
84 |
|
85 |
@auto_retry
|
86 |
+
def generate_parameters_for_sound_effect(
|
87 |
+
self, text: str, generated_audio_file: str = None
|
88 |
+
) -> dict:
|
89 |
llm_output = self.generate_text_for_sound_effect(text)
|
90 |
if generated_audio_file is not None:
|
91 |
llm_output["duration_seconds"] = get_audio_duration(generated_audio_file)
|
|
|
165 |
raise RuntimeError(f"Unexpected Error: {e}")
|
166 |
|
167 |
@auto_retry
|
168 |
+
async def generate_parameters_for_sound_effect(
|
169 |
+
self, text: str, generated_audio_file: str = None
|
170 |
+
) -> dict:
|
171 |
llm_output = await self.generate_text_for_sound_effect(text)
|
172 |
if generated_audio_file is not None:
|
173 |
llm_output["duration_seconds"] = get_audio_duration(generated_audio_file)
|