Spaces:
Running
Running
kwabs22
commited on
Commit
•
3b135aa
1
Parent(s):
742c14d
Dependencies
Browse files- app.py +75 -72
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
from googletrans import Translator
|
2 |
-
from googletrans import LANGUAGES
|
3 |
import spacy
|
4 |
import gradio as gr
|
5 |
import nltk
|
@@ -88,10 +88,10 @@ nlp_ja = spacy.load("ja_core_news_sm")
|
|
88 |
nlp_zh = spacy.load("zh_core_web_sm")
|
89 |
nlp_en_syllable = spacy.load("en_core_web_sm")
|
90 |
nlp_en_syllable.add_pipe("syllables", after="tagger") #https://spacy.io/universe/project/spacy_syllables/
|
91 |
-
langdropdown_choices = [f"{code}: {name}" for code, name in LANGUAGES.items()]
|
92 |
|
93 |
nlp = spacy.load('en_core_web_sm')
|
94 |
-
translator = Translator()
|
95 |
|
96 |
def Sentencechunker(sentence):
|
97 |
Sentchunks = sentence.split(" ")
|
@@ -163,7 +163,7 @@ def BatchWordChunk(sentence):
|
|
163 |
|
164 |
# Translate from English to French
|
165 |
|
166 |
-
langdest = gr.Dropdown(choices=langdropdown_choices, label="Choose Language", value="de: german") #["af", "de", "es", "ko", "ja", "zh-cn"]
|
167 |
|
168 |
ChunkModeDrop = gr.Dropdown(choices=["Chunks", "Reverse", "Three Word Chunks", "Spelling Chunks"], label="Choose Chunk Type", value="Chunks")
|
169 |
|
@@ -179,10 +179,10 @@ def FrontRevSentChunk (Chunkmode, Translate, Text, langdest):
|
|
179 |
if Chunkmode=="Spelling Chunks":
|
180 |
FinalOutput += BatchWordChunk(Text)
|
181 |
|
182 |
-
if Translate:
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
return FinalOutput
|
187 |
|
188 |
# Define a function to filter out non-verb, noun, or adjective words
|
@@ -251,8 +251,8 @@ def merge_lines(roman_file, w4w_file, full_mean_file, macaronic_file):
|
|
251 |
|
252 |
return "\n".join(merged_lines)
|
253 |
|
254 |
-
TTSLangOptions = gr.Dropdown(choices=langdropdown_choices, value="en: english", label="choose the language of the srt/text accent") #["en", "de", "es", "ja", "ko", "zh-cn"]
|
255 |
-
TTSLangOptions2 = gr.Dropdown(choices=langdropdown_choices, value="en: english", label="choose the language of the srt/text accent")
|
256 |
|
257 |
def TTSforListeningPractice(text, language = "en", Repeat10x = False):
|
258 |
if Repeat10x:
|
@@ -1862,32 +1862,32 @@ def lingualinkassist(text, language):
|
|
1862 |
|
1863 |
#----------------------------------------------------------------------------------------------------------------------
|
1864 |
|
1865 |
-
def w4wsidebysidereadergen(text, langdest):
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
|
1892 |
#https://huggingface.co/spaces/Geonmo/nllb-translation-demo/blob/main/app.py
|
1893 |
def nllbtranscload_models():
|
@@ -2218,8 +2218,8 @@ def nllbtrans_check_order(*inputs):
|
|
2218 |
|
2219 |
# ----------------------------------------------------------------------------------------------------
|
2220 |
|
2221 |
-
def audioformatbrainstorm(chunkmode, translate, text, langdestchoice, choice):
|
2222 |
-
FrontRevSentChunkbrainstormoutput = FrontRevSentChunk(chunkmode, translate, text, langdestchoice)
|
2223 |
AutoSyllablePracticebrainstormoutput = AutoSyllablePractice(text)
|
2224 |
RandomiseTextbyTypebrainstormoutput = RandomiseTextbyType(text, choice)
|
2225 |
create_dictionarybrainstormoutput = create_dictionary(text)
|
@@ -2228,7 +2228,8 @@ def audioformatbrainstorm(chunkmode, translate, text, langdestchoice, choice):
|
|
2228 |
SimultaneousSpellingPracbrainstormoutput = SimultaneousSpellingPrac(text)
|
2229 |
FirstLetterSummarybrainstormoutput = FirstLetterSummary(text)
|
2230 |
AutoChorusPerWordSchedulerbrainstormoutput = AutoChorusPerWordScheduler(text)
|
2231 |
-
return
|
|
|
2232 |
|
2233 |
# ----------------------------------------------------------------------------------------------------
|
2234 |
|
@@ -2677,34 +2678,34 @@ with gr.Blocks() as lliface: #theme=gr.themes.Glass(primary_hue='green', seconda
|
|
2677 |
|
2678 |
return columns + [check_button, result]
|
2679 |
|
2680 |
-
gr.HTML("Side by side reading creator (Google Translate) TODO - Roman output of Non roman characters")
|
2681 |
-
with gr.Group():
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
with gr.Tab("Reading and Grammar Assistance"):
|
2709 |
gr.HTML("Under time pressure (foreign text takes very long) the chance of just scanning the text goes up, below assists with reading the current line")
|
2710 |
with gr.Tab("General - Notetaking Reader"):
|
@@ -2927,10 +2928,11 @@ Each type of knowing involves different cognitive processes and levels of unders
|
|
2927 |
gr.HTML("Some Prompt ideas --> Prompt: Describe the place where these descriptions may be (You job is to be speculative for brainstorming purposes): A dog and a boy, the area is texas, the weather is sunny, the date is 01 May 2021 <hr> Prompt Content Ideas Ideas Clip Interrogator + Location Data aka tags for place, location and time + general news updates on the location + overview of the items in the location <br> Location based advise is most important but after that is information observed by appliances in the location eg. Times Computer turned on, times geyser inspected, amount of time keys havent been touched etc. <br> each location will have an ai personality that will relay more information ")
|
2928 |
with gr.Tab("Order Based Audio"):
|
2929 |
with gr.Tab("Audio Generation"):
|
2930 |
-
gr.
|
|
|
2931 |
gr.Label("Audio - Only English thoughts as practice")
|
2932 |
gr.HTML("For Audio Most productive is real time recall of native (where your full reasoning ability will always be) <br><hr> Find Replace new lines of the foreign text with full stops or | to get per word translation")
|
2933 |
-
gr.Interface(fn=TTSforListeningPractice, inputs=["text", TTSLangOptions2], outputs="audio", description="Paste only english words in foreign order and then keep removing the words from this to practice as effectively")
|
2934 |
with gr.Tab("Audio Format Brainstorming"):
|
2935 |
with gr.Accordion("Explanation of below brainstorm outputs", open=False):
|
2936 |
gr.HTML("Explanation of the outputs of the merged interface - FrontRevSentChunkbrainstormoutput, AutoSyllablePracticebrainstormoutput, RandomiseTextbyTypebrainstormoutput, create_dictionarybrainstormoutput, keep_nouns_verbsbrainstormoutput, split_verbs_nounsbrainstormoutput[0], split_verbs_nounsbrainstormoutput[1], split_verbs_nounsbrainstormoutput[2], SimultaneousSpellingPracbrainstormoutput, FirstLetterSummarybrainstormoutput, AutoChorusPerWordSchedulerbrainstormoutput")
|
@@ -2944,11 +2946,12 @@ Each type of knowing involves different cognitive processes and levels of unders
|
|
2944 |
gr.TextArea('', label='Paste LLM response')
|
2945 |
gr.HTML('If study content was a map the first letters shape of the whole text = Roads')
|
2946 |
gr.HTML('Known = ability to match an item to a retrieval cue instantly - Retrieval cue for the whole text = Acronym Map')
|
2947 |
-
gr.Interface(fn=audioformatbrainstorm, inputs=[ChunkModeDrop, "checkbox", "text",
|
|
|
2948 |
gr.Interface(fn=lambda sentence: ". ".join(sentence.split()), inputs=["text"], outputs=["text"], description="Use full stops before input below to make a world level version")
|
2949 |
gr.Interface(fill_lines, inputs=["text", RepSched_Num_lines], outputs="text")
|
2950 |
with gr.Accordion("Merged to one interface", open=False):
|
2951 |
-
gr.Interface(fn=FrontRevSentChunk, inputs=[ChunkModeDrop, "checkbox", "text", langdest], outputs="text", description="Chunks creator")
|
2952 |
gr.Interface(fn=AutoSyllablePractice, inputs="text", outputs="text", description="One Word At A Time | Audio Spelling Practice Using vowels as the seperator")
|
2953 |
gr.Textbox("A word is a list of letter as a fact is a list of words. Both are in a specific order. What is most important is practice the order so randomiser is the tool", lines=4)
|
2954 |
gr.Interface(fn=RandomiseTextbyType, inputs=["text", RandomiseTextType], outputs="text", description="Randomise order within words, sentences, paragrahs")
|
|
|
1 |
+
# from googletrans import Translator
|
2 |
+
# from googletrans import LANGUAGES
|
3 |
import spacy
|
4 |
import gradio as gr
|
5 |
import nltk
|
|
|
88 |
nlp_zh = spacy.load("zh_core_web_sm")
|
89 |
nlp_en_syllable = spacy.load("en_core_web_sm")
|
90 |
nlp_en_syllable.add_pipe("syllables", after="tagger") #https://spacy.io/universe/project/spacy_syllables/
|
91 |
+
# langdropdown_choices = [f"{code}: {name}" for code, name in LANGUAGES.items()]
|
92 |
|
93 |
nlp = spacy.load('en_core_web_sm')
|
94 |
+
#translator = Translator()
|
95 |
|
96 |
def Sentencechunker(sentence):
|
97 |
Sentchunks = sentence.split(" ")
|
|
|
163 |
|
164 |
# Translate from English to French
|
165 |
|
166 |
+
# langdest = gr.Dropdown(choices=langdropdown_choices, label="Choose Language", value="de: german") #["af", "de", "es", "ko", "ja", "zh-cn"]
|
167 |
|
168 |
ChunkModeDrop = gr.Dropdown(choices=["Chunks", "Reverse", "Three Word Chunks", "Spelling Chunks"], label="Choose Chunk Type", value="Chunks")
|
169 |
|
|
|
179 |
if Chunkmode=="Spelling Chunks":
|
180 |
FinalOutput += BatchWordChunk(Text)
|
181 |
|
182 |
+
# if Translate:
|
183 |
+
# TransFinalOutput = FinalOutput
|
184 |
+
# translated = translator.translate(TransFinalOutput, dest=langdest[:2])
|
185 |
+
# FinalOutput += "\n" + translated.text
|
186 |
return FinalOutput
|
187 |
|
188 |
# Define a function to filter out non-verb, noun, or adjective words
|
|
|
251 |
|
252 |
return "\n".join(merged_lines)
|
253 |
|
254 |
+
# TTSLangOptions = gr.Dropdown(choices=langdropdown_choices, value="en: english", label="choose the language of the srt/text accent") #["en", "de", "es", "ja", "ko", "zh-cn"]
|
255 |
+
# TTSLangOptions2 = gr.Dropdown(choices=langdropdown_choices, value="en: english", label="choose the language of the srt/text accent")
|
256 |
|
257 |
def TTSforListeningPractice(text, language = "en", Repeat10x = False):
|
258 |
if Repeat10x:
|
|
|
1862 |
|
1863 |
#----------------------------------------------------------------------------------------------------------------------
|
1864 |
|
1865 |
+
# def w4wsidebysidereadergen(text, langdest):
|
1866 |
+
# #FrontRevSentChunk as reference
|
1867 |
+
# FinalOutput = ""
|
1868 |
+
# Translated = "FWNWO: \n"
|
1869 |
+
# words = text.split()
|
1870 |
+
# w4wsidebysidtranslator = Translator()
|
1871 |
+
# translatedFWO = w4wsidebysidtranslator.translate(text, dest=langdest[:2])
|
1872 |
+
# translatedNWO = w4wsidebysidtranslator.translate(words, dest=langdest[:2]) #src or dest
|
1873 |
+
# #print(translated)
|
1874 |
+
# #print(dir(translatedNWO[0]), "\n")
|
1875 |
+
# #FinalOutput += "\n" + translated.text
|
1876 |
+
# for obj in translatedNWO:
|
1877 |
+
# # print(f"Original Text: {obj.origin}")
|
1878 |
+
# # print(f"Translated Text: {obj.text}")
|
1879 |
+
# # print(f"Source Language: {obj.src}")
|
1880 |
+
# # print(f"Destination Language: {obj.dest}")
|
1881 |
+
# # print(f"Pronunciation: {obj.pronunciation}\n")
|
1882 |
+
# FinalOutput += obj.origin + f" ({obj.text}) "
|
1883 |
+
# Translated += obj.text + " "
|
1884 |
+
# speech = gTTS(text=FinalOutput, lang=langdest[:2], slow="False")
|
1885 |
+
# speech.save("CurrentSidebySideTTSFile.mp3")
|
1886 |
+
|
1887 |
+
# FinalOutput = "Side by Side Version: " + FinalOutput
|
1888 |
+
|
1889 |
+
# analysisPrompt = f"{ Translated } \n\nand \n\nFWFWO: \n{ translatedFWO.text } \n\nForeign Words Native Word Order and Foreign Word Order \nIf you had to make the notes on the word by word considerations to transform FWNWO to FWFWO what would that be? (A simple game idea where your response will be the rubrik to mark the players response against)"
|
1890 |
+
# return FinalOutput, Translated, "FWFWO: \n" + translatedFWO.text, "CurrentSidebySideTTSFile.mp3", analysisPrompt
|
1891 |
|
1892 |
#https://huggingface.co/spaces/Geonmo/nllb-translation-demo/blob/main/app.py
|
1893 |
def nllbtranscload_models():
|
|
|
2218 |
|
2219 |
# ----------------------------------------------------------------------------------------------------
|
2220 |
|
2221 |
+
def audioformatbrainstorm(chunkmode, translate, text, choice): #, langdestchoice, choice):
|
2222 |
+
# FrontRevSentChunkbrainstormoutput = FrontRevSentChunk(chunkmode, translate, text, langdestchoice)
|
2223 |
AutoSyllablePracticebrainstormoutput = AutoSyllablePractice(text)
|
2224 |
RandomiseTextbyTypebrainstormoutput = RandomiseTextbyType(text, choice)
|
2225 |
create_dictionarybrainstormoutput = create_dictionary(text)
|
|
|
2228 |
SimultaneousSpellingPracbrainstormoutput = SimultaneousSpellingPrac(text)
|
2229 |
FirstLetterSummarybrainstormoutput = FirstLetterSummary(text)
|
2230 |
AutoChorusPerWordSchedulerbrainstormoutput = AutoChorusPerWordScheduler(text)
|
2231 |
+
return AutoSyllablePracticebrainstormoutput, RandomiseTextbyTypebrainstormoutput, create_dictionarybrainstormoutput, keep_nouns_verbsbrainstormoutput, split_verbs_nounsbrainstormoutput[0], split_verbs_nounsbrainstormoutput[1], split_verbs_nounsbrainstormoutput[2], SimultaneousSpellingPracbrainstormoutput, FirstLetterSummarybrainstormoutput, AutoChorusPerWordSchedulerbrainstormoutput
|
2232 |
+
#FrontRevSentChunkbrainstormoutput,
|
2233 |
|
2234 |
# ----------------------------------------------------------------------------------------------------
|
2235 |
|
|
|
2678 |
|
2679 |
return columns + [check_button, result]
|
2680 |
|
2681 |
+
gr.HTML("Side by side reading creator (Google Translate) TODO - Roman output of Non roman characters <br><br> Dependencies issues to be resolved")
|
2682 |
+
# with gr.Group():
|
2683 |
+
# with gr.Row():
|
2684 |
+
# #gr.Interface(fn=w4wsidebysidereadergen, inputs=["text", w4wsidebysidelangdest], outputs=["text", "text", "text"], description="Side by side reading creator")
|
2685 |
+
# w4wsidebysideinput = gr.Text(label="Paste Text you want to learn here (wordlists and UDHR can be used as )", placeholder="Enter Text Here. One or Two Paragraphs at the longest ideally")
|
2686 |
+
# with gr.Row():
|
2687 |
+
# w4wsidebysidelangdest = gr.Dropdown(choices=langdropdown_choices, label="Choose destination language", value="de: german")
|
2688 |
+
# #w4wsidebysideaudiosidebyside = gr.Checkbox(label="Audio for side by side")
|
2689 |
+
# w4wsidebysidebtn = gr.Button("Create Side by Side, FWNWO, and FWFWO (Just read start to finish of each till you can read the FWFWO without assistance)")
|
2690 |
+
# with gr.Row():
|
2691 |
+
# w4wsidebysideOutput = gr.Text(label="Side by side", placeholder="Side by side will display here")
|
2692 |
+
# w4wsidebysideFWNWOOutput = gr.Text(label="Foreign Word Native Word Order", placeholder="FW NWO will display here")
|
2693 |
+
# w4wsidebysideFWFWOOutput = gr.Text(label="Foreign Word Foreign Word Order", placeholder="FW FWO will display here")
|
2694 |
+
# with gr.Row():
|
2695 |
+
# w4wsidebysideaudioOutput = gr.Audio(sources=["upload"], label="Side by Side in Audio form")
|
2696 |
+
# with gr.Row():
|
2697 |
+
# w4wsidebysideAnalysisPromptOutput = gr.Text(label="Prompt for LLM analysis", placeholder="Prompt for LLM analysis will display here")
|
2698 |
+
# w4wsidebysidebtn.click(fn=w4wsidebysidereadergen, inputs=[w4wsidebysideinput, w4wsidebysidelangdest], outputs=[w4wsidebysideOutput, w4wsidebysideFWNWOOutput, w4wsidebysideFWFWOOutput, w4wsidebysideaudioOutput, w4wsidebysideAnalysisPromptOutput])
|
2699 |
+
# with gr.Row():
|
2700 |
+
# gr.HTML("To be Added")
|
2701 |
+
# with gr.Row():
|
2702 |
+
# w4wsidebysideNatSentStructOutput = gr.Text(label="Native Closed class words as Native Sentence Structure", placeholder="Comparison is valuable")
|
2703 |
+
# w4wsidebysideForSentStructOutput = gr.Text(label="Foreign Closed class words as Foreign Sentence Structure", placeholder="Comparison is valuable")
|
2704 |
+
# with gr.Row():
|
2705 |
+
# w4wsidebysideWordCountOutput = gr.Text(label="Word Count", placeholder="Word Count will display here")
|
2706 |
+
# w4wsidebysideRandomisedOutput = gr.Text(label="Random Order As Test", placeholder="Randomised version (Transition Tab most left bottom) will display here")
|
2707 |
+
# w4wsidebysideQueGenOutput = gr.Text(label="Questions generation as comprehension test", placeholder="Questions generated will display here")
|
2708 |
+
# w4wsidebysideUNWFWOOutput = gr.Text(label="HTML as UNWFWO assistant", placeholder="HTML as UNWFWO assistant download will display here")
|
2709 |
with gr.Tab("Reading and Grammar Assistance"):
|
2710 |
gr.HTML("Under time pressure (foreign text takes very long) the chance of just scanning the text goes up, below assists with reading the current line")
|
2711 |
with gr.Tab("General - Notetaking Reader"):
|
|
|
2928 |
gr.HTML("Some Prompt ideas --> Prompt: Describe the place where these descriptions may be (You job is to be speculative for brainstorming purposes): A dog and a boy, the area is texas, the weather is sunny, the date is 01 May 2021 <hr> Prompt Content Ideas Ideas Clip Interrogator + Location Data aka tags for place, location and time + general news updates on the location + overview of the items in the location <br> Location based advise is most important but after that is information observed by appliances in the location eg. Times Computer turned on, times geyser inspected, amount of time keys havent been touched etc. <br> each location will have an ai personality that will relay more information ")
|
2929 |
with gr.Tab("Order Based Audio"):
|
2930 |
with gr.Tab("Audio Generation"):
|
2931 |
+
gr.HTML("2 interfaces to be fixed due to dependency issue")
|
2932 |
+
# gr.Interface(fn=TTSforListeningPractice, inputs=["text", TTSLangOptions, "checkbox"], outputs="audio", description="gTTS - Paste chorus lyrics from below here and use TTS or make notes to save here (Or paste anything)")
|
2933 |
gr.Label("Audio - Only English thoughts as practice")
|
2934 |
gr.HTML("For Audio Most productive is real time recall of native (where your full reasoning ability will always be) <br><hr> Find Replace new lines of the foreign text with full stops or | to get per word translation")
|
2935 |
+
# gr.Interface(fn=TTSforListeningPractice, inputs=["text", TTSLangOptions2], outputs="audio", description="Paste only english words in foreign order and then keep removing the words from this to practice as effectively")
|
2936 |
with gr.Tab("Audio Format Brainstorming"):
|
2937 |
with gr.Accordion("Explanation of below brainstorm outputs", open=False):
|
2938 |
gr.HTML("Explanation of the outputs of the merged interface - FrontRevSentChunkbrainstormoutput, AutoSyllablePracticebrainstormoutput, RandomiseTextbyTypebrainstormoutput, create_dictionarybrainstormoutput, keep_nouns_verbsbrainstormoutput, split_verbs_nounsbrainstormoutput[0], split_verbs_nounsbrainstormoutput[1], split_verbs_nounsbrainstormoutput[2], SimultaneousSpellingPracbrainstormoutput, FirstLetterSummarybrainstormoutput, AutoChorusPerWordSchedulerbrainstormoutput")
|
|
|
2946 |
gr.TextArea('', label='Paste LLM response')
|
2947 |
gr.HTML('If study content was a map the first letters shape of the whole text = Roads')
|
2948 |
gr.HTML('Known = ability to match an item to a retrieval cue instantly - Retrieval cue for the whole text = Acronym Map')
|
2949 |
+
gr.Interface(fn=audioformatbrainstorm, inputs=[ChunkModeDrop, "checkbox", "text", RandomiseTextType], outputs=["text", "text", "text", "text", "text", "text", "text", "text", "text", "text"], description="Many random ideas to reorder text for testing / practice")
|
2950 |
+
#langdest
|
2951 |
gr.Interface(fn=lambda sentence: ". ".join(sentence.split()), inputs=["text"], outputs=["text"], description="Use full stops before input below to make a world level version")
|
2952 |
gr.Interface(fill_lines, inputs=["text", RepSched_Num_lines], outputs="text")
|
2953 |
with gr.Accordion("Merged to one interface", open=False):
|
2954 |
+
# gr.Interface(fn=FrontRevSentChunk, inputs=[ChunkModeDrop, "checkbox", "text", langdest], outputs="text", description="Chunks creator")
|
2955 |
gr.Interface(fn=AutoSyllablePractice, inputs="text", outputs="text", description="One Word At A Time | Audio Spelling Practice Using vowels as the seperator")
|
2956 |
gr.Textbox("A word is a list of letter as a fact is a list of words. Both are in a specific order. What is most important is practice the order so randomiser is the tool", lines=4)
|
2957 |
gr.Interface(fn=RandomiseTextbyType, inputs=["text", RandomiseTextType], outputs="text", description="Randomise order within words, sentences, paragrahs")
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
googletrans==3.1.0a0
|
2 |
torch
|
3 |
transformers
|
4 |
spacy
|
|
|
1 |
+
#googletrans==3.1.0a0
|
2 |
torch
|
3 |
transformers
|
4 |
spacy
|