sreepathi-ravikumar commited on
Commit
1ff5cd3
Β·
verified Β·
1 Parent(s): 1af330b

Create audio_scripter.py

Browse files
Files changed (1) hide show
  1. audio_scripter.py +73 -0
audio_scripter.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import httpx
3
+
4
+ def generate_audio_script(text):
5
+ try:
6
+ with httpx.Client(timeout=10.0) as client:
7
+ response = client.post(
8
+ url="https://openrouter.ai/api/v1/chat/completions",
9
+ headers={
10
+ "Authorization": f"Bearer {os.getenv('OPENROUTER_API_KEY')}",
11
+ "Content-Type": "application/json",
12
+ "HTTP-Referer": "https://sreepathi-ravikumar-sample.hf.space",
13
+ "X-Title": "Educational AI Assistant"
14
+ },
15
+ json={
16
+ "model": "deepseek/deepseek-chat-v3-0324:free",
17
+ "messages": [{
18
+ "role": "user",
19
+ "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:
20
+
21
+ ---
22
+
23
+ ### *Pure Technical Explanation Template*
24
+ *"Explain [TOPIC] in 70% spoken Tamil + 30% English technical terms, with:*
25
+ 1. *Direct definitions only* (no stories/analogies)
26
+ 2. *Plain technical breakdown* (step-by-step if needed)
27
+ 3. *Zero real-world comparisons* (no "like X" or "just as Y")
28
+
29
+ *Example Output (Topic: VPN):*
30
+ "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."
31
+
32
+ *Key Terms Used:*
33
+ - Encrypted tunnel
34
+ - VPN server
35
+ - Forward pannum
36
+ - Original IP address
37
+
38
+ ---
39
+
40
+ ### *Test Case (Topic: "SSL Encryption")*
41
+ "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."
42
+
43
+ *Contains:*
44
+ βœ… Only technical steps
45
+ βœ… Tamil verbs + English nouns
46
+ βœ… No "like" statements
47
+
48
+ ---
49
+
50
+ ### *How to Use This:*
51
+ 1. Replace *[TOPIC]* with your subject
52
+ 2. Output will be:
53
+ - What it is
54
+ - How it works (if applicable)
55
+ - Key components
56
+
57
+ *Example Request:*
58
+ "Explain DNS in this format"
59
+ βž” "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."
60
+
61
+ ---
62
+
63
+ *Understood? This is now 100% textbook-style, zero-fluff Tamil tech glossing.* """
64
+ }],
65
+ "temperature": 0.6,
66
+ "max_tokens": 2000
67
+ }
68
+ )
69
+ response.raise_for_status()
70
+ return response.json()['choices'][0]['message']['content']
71
+
72
+ except Exception as e:
73
+ return f"Error generating answer: {str(e)}"