Spaces:
Runtime error
Runtime error
hamxahbhattii
commited on
Commit
•
4bbdff0
1
Parent(s):
3644fc8
Combined Naration and Audio Book Api, Key updated
Browse files- main.py +38 -28
- summarizer.py +2 -1
main.py
CHANGED
@@ -199,39 +199,39 @@ async def get_key_info(request: Request, Summary_type: str, Summary_strategy: st
|
|
199 |
return {"status": status, "key_info": output}
|
200 |
|
201 |
|
202 |
-
@app.get("/get_narration")
|
203 |
-
async def get_narration(request: Request, Narration_style: str, text_input: str = None):
|
204 |
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
|
222 |
|
223 |
-
|
224 |
-
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
|
230 |
-
|
231 |
|
232 |
|
233 |
-
@app.get("/
|
234 |
-
async def get_audiobook(request: Request, speaker: str = "male", text_input: str = None):
|
235 |
|
236 |
# Getting User's IP
|
237 |
# user_ip = request.client.host
|
@@ -239,11 +239,21 @@ async def get_audiobook(request: Request, speaker: str = "male", text_input: str
|
|
239 |
|
240 |
# Getting Transcript if not provided
|
241 |
if not text_input:
|
242 |
-
text_input = users_context[user_ip]['
|
243 |
|
244 |
-
#
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
# Getting Status
|
249 |
status = 1 if audio_path else 0
|
|
|
199 |
return {"status": status, "key_info": output}
|
200 |
|
201 |
|
202 |
+
# @app.get("/get_narration")
|
203 |
+
# async def get_narration(request: Request, Narration_style: str, text_input: str = None):
|
204 |
|
205 |
+
# # Getting User's IP
|
206 |
+
# # user_ip = request.client.host
|
207 |
+
# user_ip = 1
|
208 |
|
209 |
+
# # Getting Transcript if not provided
|
210 |
+
# if not text_input:
|
211 |
+
# text_input = users_context[user_ip]['transcript']
|
212 |
|
213 |
+
# # # Extracting Narration
|
214 |
+
# # narrator = AudioBookNarration(text_input=text_input)
|
215 |
+
# # output = narrator.define_chain(Narration_style=Narration_style)
|
216 |
+
|
217 |
+
# temp_dir = 'temp'
|
218 |
+
# file_path = os.path.join(temp_dir, 'narration.txt')
|
219 |
+
# with open(file_path, 'r') as file:
|
220 |
+
# output = file.read()
|
221 |
|
222 |
|
223 |
+
# # Getting Status
|
224 |
+
# status = 1 if output else 0
|
225 |
|
226 |
+
# if status:
|
227 |
+
# # Storing Narration Info in the context for this user's session
|
228 |
+
# users_context[user_ip]['narration'] = output
|
229 |
|
230 |
+
# return {"status": status, "narration": output}
|
231 |
|
232 |
|
233 |
+
@app.get("/get_naration_and_audiobook")
|
234 |
+
async def get_audiobook(request: Request,Narration_style: str ,speaker: str = "male", text_input: str = None,):
|
235 |
|
236 |
# Getting User's IP
|
237 |
# user_ip = request.client.host
|
|
|
239 |
|
240 |
# Getting Transcript if not provided
|
241 |
if not text_input:
|
242 |
+
text_input = users_context[user_ip]['transcript']
|
243 |
|
244 |
+
# # Extracting Narration
|
245 |
+
|
246 |
+
# narrator = AudioBookNarration(text_input=text_input)
|
247 |
+
# output = narrator.define_chain(Narration_style=Narration_style)
|
248 |
+
|
249 |
+
# # Generating Audiobook
|
250 |
+
# audiobook = AudioBook(output_folder=output_folder)
|
251 |
+
# audio_path = audiobook.generate_audio_from_text(output, speaker=speaker, filename="output_audio")
|
252 |
+
|
253 |
+
temp_dir = 'temp'
|
254 |
+
file_path = os.path.join(temp_dir, 'narration.txt')
|
255 |
+
|
256 |
+
audio_path = file_path
|
257 |
|
258 |
# Getting Status
|
259 |
status = 1 if audio_path else 0
|
summarizer.py
CHANGED
@@ -15,7 +15,8 @@ from collections import Counter
|
|
15 |
# import nltk
|
16 |
from nltk.corpus import stopwords
|
17 |
|
18 |
-
|
|
|
19 |
|
20 |
class Extract_Summary:
|
21 |
|
|
|
15 |
# import nltk
|
16 |
from nltk.corpus import stopwords
|
17 |
|
18 |
+
## Added Key that is provided by Yasir bahi
|
19 |
+
os.environ["OPENAI_API_KEY"] = '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'
|
20 |
|
21 |
class Extract_Summary:
|
22 |
|