sample / audio_scripter.py
sreepathi-ravikumar's picture
Create audio_scripter.py
1ff5cd3 verified
import os
import httpx
def generate_audio_script(text):
try:
with httpx.Client(timeout=10.0) as client:
response = client.post(
url="https://openrouter.ai/api/v1/chat/completions",
headers={
"Authorization": f"Bearer {os.getenv('OPENROUTER_API_KEY')}",
"Content-Type": "application/json",
"HTTP-Referer": "https://sreepathi-ravikumar-sample.hf.space",
"X-Title": "Educational AI Assistant"
},
json={
"model": "deepseek/deepseek-chat-v3-0324:free",
"messages": [{
"role": "user",
"content": f"""topic:\n{text} \n prompt :\n Understood. Here's your *strictly concept-only* explanation format in 70% Tamil + 30% English technical terms, with zero analogies/metaphors/examples:
---
### *Pure Technical Explanation Template*
*"Explain [TOPIC] in 70% spoken Tamil + 30% English technical terms, with:*
1. *Direct definitions only* (no stories/analogies)
2. *Plain technical breakdown* (step-by-step if needed)
3. *Zero real-world comparisons* (no "like X" or "just as Y")
*Example Output (Topic: VPN):*
"VPN oru encrypted tunnel create pannum. Un device internet-la connect aagum pothu, data first VPN server-ku poganum. Server encrypt panni destination-ku forward pannum. ISP, hackers, oru third-party um un original IP address-ah pakka mudiyadhu."
*Key Terms Used:*
- Encrypted tunnel
- VPN server
- Forward pannum
- Original IP address
---
### *Test Case (Topic: "SSL Encryption")*
"SSL oru security protocol. Itha use panna, client-server communication encrypt aagum. Public key & private key combination use panni data-ah scramble pannum. Mana browser-la padlock symbol kaanum - idhu SSL active-nu solradhu."
*Contains:*
βœ… Only technical steps
βœ… Tamil verbs + English nouns
βœ… No "like" statements
---
### *How to Use This:*
1. Replace *[TOPIC]* with your subject
2. Output will be:
- What it is
- How it works (if applicable)
- Key components
*Example Request:*
"Explain DNS in this format"
βž” "DNS oru domain name-ah IP address-ah convert pannum. Browser-la URL type panna, DNS server athuku corresponding IP-ah kandupudikum. Appo server-ku correct address-la request pogum."
---
*Understood? This is now 100% textbook-style, zero-fluff Tamil tech glossing.* """
}],
"temperature": 0.6,
"max_tokens": 2000
}
)
response.raise_for_status()
return response.json()['choices'][0]['message']['content']
except Exception as e:
return f"Error generating answer: {str(e)}"