fix output folder permissions
Browse files- src/audio_generation.py +9 -4
src/audio_generation.py
CHANGED
|
@@ -7,9 +7,14 @@ from pydub import AudioSegment
|
|
| 7 |
import base64
|
| 8 |
from pathlib import Path
|
| 9 |
from script_generation import PodScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
@dataclass
|
| 11 |
class AudioConfig:
|
| 12 |
-
output_path: str =
|
| 13 |
api_key: str = os.getenv("OPENAI_API_KEY", "")
|
| 14 |
model: str = "gpt-4o-mini-tts"
|
| 15 |
mocked: bool = False
|
|
@@ -92,9 +97,9 @@ class ScriptToAudio:
|
|
| 92 |
"""
|
| 93 |
random_bytes = os.urandom(8)
|
| 94 |
folder_name = base64.urlsafe_b64encode(random_bytes).decode("utf-8")
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
return
|
| 98 |
|
| 99 |
def _combine_audio_files(self, filenames: List[str], output_file: str) -> None:
|
| 100 |
"""Combines multiple audio files into a single WAV file.
|
|
|
|
| 7 |
import base64
|
| 8 |
from pathlib import Path
|
| 9 |
from script_generation import PodScript
|
| 10 |
+
|
| 11 |
+
output_root = Path(tempfile.gettempdir()) / "upvoice_outputs"
|
| 12 |
+
output_root.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
@dataclass
|
| 16 |
class AudioConfig:
|
| 17 |
+
output_path: str = str(output_root)
|
| 18 |
api_key: str = os.getenv("OPENAI_API_KEY", "")
|
| 19 |
model: str = "gpt-4o-mini-tts"
|
| 20 |
mocked: bool = False
|
|
|
|
| 97 |
"""
|
| 98 |
random_bytes = os.urandom(8)
|
| 99 |
folder_name = base64.urlsafe_b64encode(random_bytes).decode("utf-8")
|
| 100 |
+
final_folder = Path(self._config.output_path) / folder_name
|
| 101 |
+
final_folder.mkdir(parents=True, exist_ok=True)
|
| 102 |
+
return str(final_folder)
|
| 103 |
|
| 104 |
def _combine_audio_files(self, filenames: List[str], output_file: str) -> None:
|
| 105 |
"""Combines multiple audio files into a single WAV file.
|