aboutsummaryrefslogtreecommitdiffstats
path: root/devourer.py
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-12-01 08:56:31 +0000
committerterminaldweller <thabogre@gmail.com>2021-12-01 08:56:31 +0000
commit797d1b874e6968ee1b38db8efa1ee70249536ed0 (patch)
treea0f01fc15ea151b6368d9dd00a729532e70ba464 /devourer.py
parentreqs is working fot text mode. (diff)
downloaddevourer-797d1b874e6968ee1b38db8efa1ee70249536ed0.tar.gz
devourer-797d1b874e6968ee1b38db8efa1ee70249536ed0.zip
added README. /wiki is working now.
Diffstat (limited to 'devourer.py')
-rw-r--r--devourer.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/devourer.py b/devourer.py
index 75f469b..8196050 100644
--- a/devourer.py
+++ b/devourer.py
@@ -242,7 +242,7 @@ def summarizeLinksToAudio(url, summary) -> None:
return result
-def searchWikipedia(search_term: str) -> str:
+def searchWikipedia(search_term: str, summary: str) -> str:
"""Search wikipedia for a string and return the url.
reference: https://www.mediawiki.org/wiki/API:Opensearch
@@ -259,7 +259,7 @@ def searchWikipedia(search_term: str) -> str:
res = getWithParams(os.environ["WIKI_SEARCH_URL"], searchParmas)
# FIXME-handle wiki redirects/disambiguations
source = res[3][0]
- result = summarizeLinkToAudio(source, "none")
+ result = summarizeLinkToAudio(source, summary)
except Exception as e:
logging.exception(e)
finally:
@@ -298,12 +298,12 @@ def extract_reqs_ep(url: str, sourcetype: str = "html"):
@app.get("/mila/wiki")
-def wiki_search_ep(term: str, audio: bool = False):
+def wiki_search_ep(term: str, summary: str = "none", audio: bool = False):
"""search and summarizes from wikipedia"""
- text = searchWikipedia(term)
+ text = searchWikipedia(term, summary)
if audio:
audio_path = textToAudio(text)
- return FastAPI(
+ return APIResponse(
getAudioFromFile(audio_path) if audio_path != "" else "",
media_type="audio/mpeg",
)