deepsync commited on
Commit
6f1b639
·
verified ·
1 Parent(s): 5aabdde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -0
app.py CHANGED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from time import sleep
3
+
4
+
5
+ def indian_notation(num):
6
+ num_str = str(num)
7
+ if '.' in num_str:
8
+ num_str = '{:.2f}'.format(float(num_str)).rstrip('0').rstrip('.')
9
+ integer_part, decimal_part = num_str.split(".")
10
+ decimal_part = "." + decimal_part
11
+ else:
12
+ integer_part, decimal_part = num_str, ""
13
+ rev = integer_part[::-1]
14
+ if len(rev) < 4:
15
+ return rev[::-1] + decimal_part
16
+ three_part, rest = rev[:3], rev[3:]
17
+ rest = ",".join([rest[i:i+2] for i in range(0, len(rest), 2)])
18
+ return (rest[::-1] + "," + three_part[::-1]) + decimal_part
19
+
20
+
21
+ def compute_roi(avg_duration, estd_courses, course_price, price_dubbing, course_name):
22
+ sleep(1)
23
+ estd_courses = float(estd_courses)
24
+ avg_duration = float(avg_duration)
25
+ course_price = float(course_price)
26
+ price_dubbing = float(price_dubbing)
27
+ new_markdown = f"""## ROI for Course: <ins>{course_name}</ins>
28
+ ## _For a batch of **{int(estd_courses)}** students, for average **{avg_duration:g} hours** of duration, you are expected to earn ₹{indian_notation(int(estd_courses * course_price))}._
29
+ ## _The estimated cost for dubbing this course is ₹{indian_notation(int(price_dubbing*60*avg_duration))}, paid in monthly installments._
30
+ ## _Your ROI is approximately {int((estd_courses * course_price) / (price_dubbing*60*avg_duration) * 100)}%._
31
+ """
32
+ return gr.update(value=new_markdown, visible=True)
33
+
34
+ with gr.Blocks(theme="gradio/monochrome") as demo:
35
+ gr.Markdown("# Dubbing Course ROI Calculator")
36
+ with gr.Row():
37
+ course_name_txt = gr.Textbox(label="Course Name")
38
+ category = gr.Dropdown(["CA", "Finance", "JEE", "CMA", "NEET", "Biology", "Chemistry", "Physics", "Others"], label="Course Category")
39
+ with gr.Row():
40
+ avg_duration_num = gr.Number(label="Average Duration (hours)")
41
+ num_courses = gr.Number(label="Number of Courses")
42
+ course_price_txt = gr.Textbox(label="Estimated Course Price")
43
+ with gr.Row():
44
+ source_lang = gr.Dropdown(["English", "Hindi", "Tamil"], label="Source Language")
45
+ target_lang = gr.Dropdown(["English", "Hindi", "Tamil"], label="Target Language")
46
+ with gr.Row():
47
+ estd_courses_num = gr.Number(label="Estimated Dubbed Courses Sold", info="Assuming one person buys one course.")
48
+ price_dubbing_txt = gr.Textbox(label="Dubpro's Per Minute Price", info="This price is inclusive of GST.")
49
+
50
+ calc_roi = gr.Button("Calculate ROI")
51
+
52
+ output = gr.Markdown()
53
+
54
+ calc_roi.click(compute_roi, [avg_duration_num, estd_courses_num, course_price_txt, price_dubbing_txt, course_name_txt], output)
55
+
56
+ demo.launch(auth=(os.environ.get("USERNAME"), os.environ.get("PASSWORD")))