Lakpriya Seneviratna commited on
Commit
90bc8ef
·
1 Parent(s): 92a7a68

chore: Create audio output folder if it doesn't exist

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -33,6 +33,13 @@ import uuid
33
 
34
  # Define the output folder path
35
  output_folder = 'output'
 
 
 
 
 
 
 
36
 
37
  # Constants
38
  SCOPES = ["https://www.googleapis.com/auth/youtube.upload"]
@@ -45,10 +52,6 @@ MAX_RETRIES = 10
45
  RETRIABLE_STATUS_CODES = [500, 502, 503, 504]
46
  ELEVENLABS_KEY = "153f3875b30f603644cc66a78f1345ea"
47
 
48
- # Check if the folder exists, if not, create it
49
- if not os.path.exists(output_folder):
50
- os.makedirs(output_folder)
51
-
52
  banned_words = ["fuck", "pussy", "ass", "porn", "gay", "dick", "cock", "kill", "fucking", "shit", "bitch", "bullshit", "asshole","douchebag", "bitch", "motherfucker", "nigga","cunt", "whore", "piss", "shoot", "bomb", "palestine", "israel" ]
53
 
54
  def contains_banned_word(text, banned_words):
@@ -232,7 +235,7 @@ def tts_per_sentence(sentences, output_folder, silence_duration=1000):
232
 
233
  for index, sentence in enumerate(sentences):
234
  output_file = f'{output_folder}/voiceover_{index}.wav'
235
- text_to_speech_using_speecht5(sentence, output_file)
236
  audio = AudioSegment.from_wav(output_file)
237
  silence = AudioSegment.silent(duration=silence_duration)
238
  audio_with_silence = audio + silence
 
33
 
34
  # Define the output folder path
35
  output_folder = 'output'
36
+ audio_output_folder = 'audio'
37
+
38
+ if not os.path.exists(audio_output_folder):
39
+ os.makedirs(audio_output_folder)
40
+
41
+ if not os.path.exists(output_folder):
42
+ os.makedirs(output_folder)
43
 
44
  # Constants
45
  SCOPES = ["https://www.googleapis.com/auth/youtube.upload"]
 
52
  RETRIABLE_STATUS_CODES = [500, 502, 503, 504]
53
  ELEVENLABS_KEY = "153f3875b30f603644cc66a78f1345ea"
54
 
 
 
 
 
55
  banned_words = ["fuck", "pussy", "ass", "porn", "gay", "dick", "cock", "kill", "fucking", "shit", "bitch", "bullshit", "asshole","douchebag", "bitch", "motherfucker", "nigga","cunt", "whore", "piss", "shoot", "bomb", "palestine", "israel" ]
56
 
57
  def contains_banned_word(text, banned_words):
 
235
 
236
  for index, sentence in enumerate(sentences):
237
  output_file = f'{output_folder}/voiceover_{index}.wav'
238
+ text_to_speech_using_speecht5(sentence, audio_output_folder)
239
  audio = AudioSegment.from_wav(output_file)
240
  silence = AudioSegment.silent(duration=silence_duration)
241
  audio_with_silence = audio + silence