breddaz commited on
Commit
8db2fc1
·
1 Parent(s): 16675c0

fix output folder permissions

Browse files
Files changed (1) hide show
  1. 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 = "./src/public/output"
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
- final_folder_name = os.path.join(self._config.output_path, folder_name)
96
- os.makedirs(final_folder_name, exist_ok=True)
97
- return final_folder_name
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.