-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import requests | ||
|
||
API_KEY="cm9uaWRhczA0MTk4N0BnbWFpbC5jb20:vU6fHQuEgIZK6zzLY8QK2" | ||
|
||
def download_video(id): | ||
url = "https://api.d-id.com/talks/"+id | ||
|
||
headers = { | ||
"accept": "application/json", | ||
"authorization": f"Basic {API_KEY}" | ||
} | ||
|
||
response = requests.get(url, headers=headers) | ||
print(response.json()) | ||
url=response.json()["result_url"] | ||
|
||
return url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import requests | ||
|
||
API_KEY="cm9uaWRhczA0MTk4N0BnbWFpbC5jb20:vU6fHQuEgIZK6zzLY8QK2" | ||
|
||
url = "https://api.d-id.com/talks" | ||
|
||
def genvideo(img_url,summary,v_id): | ||
|
||
payload = { | ||
"source_url":img_url, | ||
"script": { | ||
"type": "text", | ||
"input": summary, | ||
"provider": { | ||
"type": "microsoft", | ||
"voice_id": v_id, | ||
"voice_config":{ | ||
"style":"Default" | ||
} | ||
} | ||
} | ||
} | ||
headers = { | ||
"accept": "application/json", | ||
"content-type": "application/json", | ||
"authorization": f"Basic {API_KEY}" | ||
} | ||
|
||
response = requests.post(url, json=payload, headers=headers) | ||
|
||
id=response.json()["id"] | ||
print(id) | ||
return id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import streamlit as st | ||
from langchain_openai import ChatOpenAI | ||
from langchain_community.tools import DuckDuckGoSearchResults | ||
from langchain.docstore.document import Document | ||
from langchain.chains.summarize import load_summarize_chain | ||
from langchain.prompts import PromptTemplate | ||
from genvideo import genvideo | ||
from downloadvideo import download_video | ||
import time | ||
llm=ChatOpenAI(model="gpt-4",temperature=0.0) | ||
ts=""" | ||
you are a news anchor for a global news channel,with this context genereate a concise summary of ther following | ||
{text} | ||
""" | ||
pt=PromptTemplate(template=ts,input_variables=["text"]) | ||
st.set_page_config(page_title="24/7 NEWS CHANNEL POWERED BY AI DRIVEN NEWS ANCHOR") | ||
st.header="what you want to hear and watch" | ||
qsn=st.text_area("enter your query") | ||
search=DuckDuckGoSearchResults(backend="news") | ||
if st.button("Submit",type="primary"): | ||
if qsn is not None: | ||
result=search.run(qsn) | ||
data=result.replace("[snippet: ","") | ||
data=data[:-1] | ||
docs=[Document(page_content=t) for t in data] | ||
chain=load_summarize_chain(llm,chain_type="stuff",prompt=pt) | ||
summary=chain.run(docs) | ||
id=genvideo("https://clips-presenters.d-id.com/lana/uXbrIxQFjr/kzlKYBZ2wc/image.png",summary,"en-US-JaneNeural") | ||
time.sleep(100) | ||
url=download_video(id) | ||
st.video(url) | ||
|
||
|
Binary file not shown.