deepsync commited on
Commit
4203f55
1 Parent(s): d7e36aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -82,19 +82,24 @@ def dubpro_english_transliteration(text):
82
  return response_content
83
 
84
 
85
- def generate_rephrases_gemini(text):
86
- API_URL = os.environ.get("GEMINI_FINETUNED_HINDI_ENG_API")
87
  BEARER_TOKEN = get_google_token()
88
  headers = {
89
  "Authorization": f"Bearer {BEARER_TOKEN}",
90
  "Content-Type": "application/json",
91
  }
 
 
 
 
 
92
  payload = {
93
  "contents": [
94
  {
95
  "parts": [
96
  {
97
- "text": "You are a language expert. Return rephrases of the provided text without any loss in information keeping the same tone and style of text, so that it takes a little less time when generating audio. Return only the outputs in a new line."
98
  },
99
  {
100
  "text": f"input: {text}"
@@ -123,7 +128,7 @@ def generate_rephrases_gemini(text):
123
  output_text = response["candidates"][0]["content"]["parts"][0]["text"]
124
 
125
  texts = list(map(lambda x: x.replace("-", "").strip(), output_text.split("\n")))
126
- return texts
127
 
128
 
129
  with gr.Blocks() as demo:
@@ -137,9 +142,10 @@ with gr.Blocks() as demo:
137
  gr.Markdown("Rephraser Tool")
138
  with gr.Row():
139
  rephrase_text = gr.Textbox(label="Input text", info="Please enter text.")
 
140
  rephrased_text = gr.Textbox(label="Output text")
141
  rephrase = gr.Button("Submit")
142
- rephrase.click(generate_rephrases_gemini, rephrase_text, rephrased_text)
143
 
144
 
145
  demo.launch(auth=(os.environ.get("USERNAME"), os.environ.get("PASSWORD")))
 
82
  return response_content
83
 
84
 
85
+ def generate_rephrases_gemini(text, language):
86
+ API_URL = os.environ.get("GEMINI_REPHRASER_API")
87
  BEARER_TOKEN = get_google_token()
88
  headers = {
89
  "Authorization": f"Bearer {BEARER_TOKEN}",
90
  "Content-Type": "application/json",
91
  }
92
+ if language == "English":
93
+ prompt = "You are an English and Hindi language expert, please rephrase a sentence that has been translated from Hindi to English so that it takes little less time to speak."
94
+ elif language == "Hindi":
95
+ prompt = "You are a hindi language expert please rephrase the below line without summary so that it takes little less time to speak in hinglish manner."
96
+
97
  payload = {
98
  "contents": [
99
  {
100
  "parts": [
101
  {
102
+ "text": prompt
103
  },
104
  {
105
  "text": f"input: {text}"
 
128
  output_text = response["candidates"][0]["content"]["parts"][0]["text"]
129
 
130
  texts = list(map(lambda x: x.replace("-", "").strip(), output_text.split("\n")))
131
+ return "\n".join(texts)
132
 
133
 
134
  with gr.Blocks() as demo:
 
142
  gr.Markdown("Rephraser Tool")
143
  with gr.Row():
144
  rephrase_text = gr.Textbox(label="Input text", info="Please enter text.")
145
+ language = gr.Dropdown(["English", "Hindi"], value="Hindi")
146
  rephrased_text = gr.Textbox(label="Output text")
147
  rephrase = gr.Button("Submit")
148
+ rephrase.click(generate_rephrases_gemini, [rephrase_text, laguage], rephrased_text)
149
 
150
 
151
  demo.launch(auth=(os.environ.get("USERNAME"), os.environ.get("PASSWORD")))