Update app.py
Browse files9 unmodified lines10111213141516 unmodified lines3233343536373 unmodified lines414243444546479 unmodified lines575859606162639 unmodified lines'Spanish': "Helsinki-NLP/opus-mt-en-es"}# Initialize translation pipelinedef get_translator(language):model_name = translation_models.get(language)16 unmodified linesreturn "\n".join(f"- {point}" for point in bullet_points)# Helper function to translate textdef translate_text(text, language):translator = get_translator(language)3 unmodified linesreturn textdef process_text(input_text, language):bullet_points = generate_bullet_points(input_text)translated_text = translate_text(bullet_points, language)return bullet_points, translated_text9 unmodified linesgr.Textbox(label="Translated Bullet Points")],title="Text to Bullet Points and Translation",description="Paste any text, and the program will transform it into bullet points. Optionally, translate the bullet points into Vietnamese, Japanese, Thai, or Spanish.")iface.launch()9 unmodified lines10111213141516171816 unmodified lines35363738394041424344453 unmodified lines49505152535455569 unmodified lines66676869707172739 unmodified lines'Spanish': "Helsinki-NLP/opus-mt-en-es"}# Initialize summarization pipelinesummarizer = pipeline("summarization")# Initialize translation pipelinedef get_translator(language):model_name = translation_models.get(language)16 unmodified linesreturn "\n".join(f"- {point}" for point in bullet_points)# Helper function to summarize textdef summarize_text(text):summary = summarizer(text, max_length=150, min_length=40, do_sample=False)return summary[0]['summary_text']# Helper function to translate textdef translate_text(text, language):translator = get_translator(language)3 unmodified linesreturn textdef process_text(input_text, language):summary = summarize_text(input_text)bullet_points = generate_bullet_points(summary)translated_text = translate_text(bullet_points, language)return bullet_points, translated_text9 unmodified linesgr.Textbox(label="Translated Bullet Points")],title="Text to Bullet Points and Translation",description="Paste any text, and the program will summarize it into bullet points. Optionally, translate the bullet points into Vietnamese, Japanese, Thai, or Spanish.")iface.launch()
app.py+12-2