uzi007 commited on
Commit
1d7e794
1 Parent(s): 8dfcf9b

Added Audio Download in Transcription

Browse files
Files changed (1) hide show
  1. main.py +25 -18
main.py CHANGED
@@ -125,13 +125,23 @@ async def download_media(user_id: str, media_type: str, media_format: str, media
125
  @app.get("/get_transcript")
126
  async def get_transcript(user_id: str, subtitle_format: str = 'srt', word_level: bool = False):
127
 
128
- # Retrieving the media_path from the context for this user's session
129
- media_path = users_context[user_id]['media_path']
130
 
131
- # Checking if the media_type is Video, then extract it's audio
132
- media_type = users_context[user_id]['media_type']
133
- if media_type == 'video':
134
- media_path = extract_audio(media_path)
 
 
 
 
 
 
 
 
 
 
135
 
136
  # # Whisper based transcription
137
  # stable_whisper_transcript = StableWhisper(media_path, output_folder, subtitle_format=subtitle_format, word_level=word_level)
@@ -195,11 +205,10 @@ async def get_translation(user_id: str, target_language: str = 'en'):
195
 
196
  @app.get("/get_summary")
197
  async def get_summary(user_id: str, Summary_type: str, Summary_strategy: str, Target_Person_type: str,
198
- Response_length: str, Writing_style: str, text_input: str = None):
199
 
200
- # Getting Transcript if not provided
201
- if not text_input:
202
- text_input = users_context[user_id]['transcript']
203
 
204
  # # Extracting Summary
205
  # summary_extractor = Extract_Summary(text_input=text_input)
@@ -228,11 +237,10 @@ async def get_summary(user_id: str, Summary_type: str, Summary_strategy: str, Ta
228
 
229
  @app.get("/get_key_info")
230
  async def get_key_info(user_id: str, Summary_type: str, Summary_strategy: str, Target_Person_type: str,
231
- Response_length: str, Writing_style: str, text_input: str = None):
232
 
233
- # Getting Transcript if not provided
234
- if not text_input:
235
- text_input = users_context[user_id]['transcript']
236
 
237
  # # Extracting Summary
238
  # summary_extractor = Extract_Summary(text_input=text_input)
@@ -260,12 +268,11 @@ async def get_key_info(user_id: str, Summary_type: str, Summary_strategy: str, T
260
 
261
 
262
  @app.get("/get_audiobook")
263
- async def get_audiobook(user_id: str, narration_style: str, speaker: str = "male", text_input: str = None,
264
  audio_format: str = "mp3", audio_quality: str = "128kbps"):
265
 
266
- # Getting Transcript if not provided
267
- if not text_input:
268
- text_input = users_context[user_id]['transcript']
269
 
270
  # # Extracting Narration
271
 
 
125
  @app.get("/get_transcript")
126
  async def get_transcript(user_id: str, subtitle_format: str = 'srt', word_level: bool = False):
127
 
128
+ # If Video Already Downloaded
129
+ if 'media_path' in users_context[user_id].keys():
130
 
131
+ # Retrieving the media_path from the context for this user's session
132
+ media_path = users_context[user_id]['media_path']
133
+
134
+ # Checking if the media_type is Video, then extract it's audio
135
+ media_type = users_context[user_id]['media_type']
136
+ if media_type == 'video':
137
+ media_path = extract_audio(media_path)
138
+
139
+ else:
140
+
141
+ # Downloading Audio for Transcription
142
+ media_path = users_context[user_id]['downloader'].download('audio', 'mp3', '128kbps')
143
+
144
+ # Retrieving Audio
145
 
146
  # # Whisper based transcription
147
  # stable_whisper_transcript = StableWhisper(media_path, output_folder, subtitle_format=subtitle_format, word_level=word_level)
 
205
 
206
  @app.get("/get_summary")
207
  async def get_summary(user_id: str, Summary_type: str, Summary_strategy: str, Target_Person_type: str,
208
+ Response_length: str, Writing_style: str):
209
 
210
+ # Getting Transcript
211
+ text_input = users_context[user_id]['transcript']
 
212
 
213
  # # Extracting Summary
214
  # summary_extractor = Extract_Summary(text_input=text_input)
 
237
 
238
  @app.get("/get_key_info")
239
  async def get_key_info(user_id: str, Summary_type: str, Summary_strategy: str, Target_Person_type: str,
240
+ Response_length: str, Writing_style: str):
241
 
242
+ # Getting Transcript
243
+ text_input = users_context[user_id]['transcript']
 
244
 
245
  # # Extracting Summary
246
  # summary_extractor = Extract_Summary(text_input=text_input)
 
268
 
269
 
270
  @app.get("/get_audiobook")
271
+ async def get_audiobook(user_id: str, narration_style: str, speaker: str = "male",
272
  audio_format: str = "mp3", audio_quality: str = "128kbps"):
273
 
274
+ # Getting Transcript
275
+ text_input = users_context[user_id]['transcript']
 
276
 
277
  # # Extracting Narration
278