Spaces:
Runtime error
Runtime error
Commit
•
6c4f541
0
Parent(s):
Duplicate from KwabsHug/Language-Learn-Idea
Browse filesCo-authored-by: Kwabena Anim <[email protected]>
- .gitattributes +34 -0
- README.md +13 -0
- ShortBaby.ttf +0 -0
- app.py +956 -0
- requirements.txt +12 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Language Learn Idea
|
3 |
+
emoji: 🚀
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: gray
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.16.2
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: KwabsHug/Language-Learn-Idea
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
ShortBaby.ttf
ADDED
Binary file (28.5 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,956 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from googletrans import Translator
|
2 |
+
import spacy
|
3 |
+
import gradio as gr
|
4 |
+
import nltk
|
5 |
+
from nltk.corpus import wordnet
|
6 |
+
import wikipedia
|
7 |
+
import re
|
8 |
+
import time
|
9 |
+
import random
|
10 |
+
import os
|
11 |
+
import zipfile
|
12 |
+
import ffmpeg
|
13 |
+
from gtts import gTTS
|
14 |
+
#from io import BytesIO
|
15 |
+
from collections import Counter
|
16 |
+
from PIL import Image, ImageDraw, ImageFont
|
17 |
+
import numpy as np
|
18 |
+
from docx import Document
|
19 |
+
import textwrap
|
20 |
+
import pandas as pd
|
21 |
+
|
22 |
+
#Uncomment these for Huggingface
|
23 |
+
nltk.download('maxent_ne_chunker') #Chunker
|
24 |
+
nltk.download('stopwords') #Stop Words List (Mainly Roman Languages)
|
25 |
+
nltk.download('words') #200 000+ Alphabetical order list
|
26 |
+
nltk.download('punkt') #Tokenizer
|
27 |
+
nltk.download('verbnet') #For Description of Verbs
|
28 |
+
nltk.download('omw')
|
29 |
+
nltk.download('omw-1.4') #Multilingual Wordnet
|
30 |
+
nltk.download('wordnet') #For Definitions, Antonyms and Synonyms
|
31 |
+
nltk.download('shakespeare')
|
32 |
+
nltk.download('dolch') #Sight words
|
33 |
+
nltk.download('names') #People Names NER
|
34 |
+
nltk.download('gazetteers') #Location NER
|
35 |
+
nltk.download('opinion_lexicon') #Sentiment words
|
36 |
+
nltk.download('averaged_perceptron_tagger') #Parts of Speech Tagging
|
37 |
+
|
38 |
+
spacy.cli.download("en_core_web_sm")
|
39 |
+
spacy.cli.download('ko_core_news_sm')
|
40 |
+
spacy.cli.download('ja_core_news_sm')
|
41 |
+
spacy.cli.download('zh_core_web_sm')
|
42 |
+
|
43 |
+
nlp = spacy.load('en_core_web_sm')
|
44 |
+
translator = Translator()
|
45 |
+
|
46 |
+
def Sentencechunker(sentence):
|
47 |
+
Sentchunks = sentence.split(" ")
|
48 |
+
chunks = []
|
49 |
+
for i in range(len(Sentchunks)):
|
50 |
+
chunks.append(" ".join(Sentchunks[:i+1]))
|
51 |
+
return " | ".join(chunks)
|
52 |
+
|
53 |
+
def ReverseSentenceChunker(sentence):
|
54 |
+
reversed_sentence = " ".join(reversed(sentence.split()))
|
55 |
+
chunks = Sentencechunker(reversed_sentence)
|
56 |
+
return chunks
|
57 |
+
|
58 |
+
def three_words_chunk(sentence):
|
59 |
+
words = sentence.split()
|
60 |
+
chunks = [words[i:i+3] for i in range(len(words)-2)]
|
61 |
+
chunks = [" ".join(chunk) for chunk in chunks]
|
62 |
+
return " | ".join(chunks)
|
63 |
+
|
64 |
+
def keep_nouns_verbs(sentence):
|
65 |
+
doc = nlp(sentence)
|
66 |
+
nouns_verbs = []
|
67 |
+
for token in doc:
|
68 |
+
if token.pos_ in ['NOUN','VERB','PUNCT']:
|
69 |
+
nouns_verbs.append(token.text)
|
70 |
+
return " ".join(nouns_verbs)
|
71 |
+
|
72 |
+
def unique_word_count(text="", state=None):
|
73 |
+
if state is None:
|
74 |
+
state = {}
|
75 |
+
words = text.split()
|
76 |
+
word_counts = state
|
77 |
+
for word in words:
|
78 |
+
if word in word_counts:
|
79 |
+
word_counts[word] += 1
|
80 |
+
else:
|
81 |
+
word_counts[word] = 1
|
82 |
+
sorted_word_counts = sorted(word_counts.items(), key=lambda x: x[1], reverse=True)
|
83 |
+
return sorted_word_counts,
|
84 |
+
|
85 |
+
def Wordchunker(word):
|
86 |
+
chunks = []
|
87 |
+
for i in range(len(word)):
|
88 |
+
chunks.append(word[:i+1])
|
89 |
+
return chunks
|
90 |
+
|
91 |
+
def BatchWordChunk(sentence):
|
92 |
+
words = sentence.split(" ")
|
93 |
+
FinalOutput = ""
|
94 |
+
Currentchunks = ""
|
95 |
+
ChunksasString = ""
|
96 |
+
for word in words:
|
97 |
+
ChunksasString = ""
|
98 |
+
Currentchunks = Wordchunker(word)
|
99 |
+
for chunk in Currentchunks:
|
100 |
+
ChunksasString += chunk + " "
|
101 |
+
FinalOutput += "\n" + ChunksasString
|
102 |
+
return FinalOutput
|
103 |
+
|
104 |
+
# Translate from English to French
|
105 |
+
|
106 |
+
langdest = gr.Dropdown(choices=["af", "de", "es", "ko", "ja", "zh-cn"], label="Choose Language", value="de")
|
107 |
+
|
108 |
+
ChunkModeDrop = gr.Dropdown(choices=["Chunks", "Reverse", "Three Word Chunks", "Spelling Chunks"], label="Choose Chunk Type", value="Chunks")
|
109 |
+
|
110 |
+
def FrontRevSentChunk (Chunkmode, Translate, Text, langdest):
|
111 |
+
FinalOutput = ""
|
112 |
+
TransFinalOutput = ""
|
113 |
+
if Chunkmode=="Chunks":
|
114 |
+
FinalOutput += Sentencechunker(Text)
|
115 |
+
if Chunkmode=="Reverse":
|
116 |
+
FinalOutput += ReverseSentenceChunker(Text)
|
117 |
+
if Chunkmode=="Three Word Chunks":
|
118 |
+
FinalOutput += three_words_chunk(Text)
|
119 |
+
if Chunkmode=="Spelling Chunks":
|
120 |
+
FinalOutput += BatchWordChunk(Text)
|
121 |
+
|
122 |
+
if Translate:
|
123 |
+
TransFinalOutput = FinalOutput
|
124 |
+
translated = translator.translate(TransFinalOutput, dest=langdest)
|
125 |
+
FinalOutput += "\n" + translated.text
|
126 |
+
return FinalOutput
|
127 |
+
|
128 |
+
# Define a function to filter out non-verb, noun, or adjective words
|
129 |
+
def filter_words(words):
|
130 |
+
# Use NLTK to tag each word with its part of speech
|
131 |
+
tagged_words = nltk.pos_tag(words)
|
132 |
+
|
133 |
+
# Define a set of parts of speech to keep (verbs, nouns, adjectives)
|
134 |
+
keep_pos = {'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ', 'NN', 'NNS', 'NNP', 'NNPS', 'JJ', 'JJR', 'JJS'}
|
135 |
+
|
136 |
+
# Filter the list to only include words with the desired parts of speech
|
137 |
+
filtered_words = [word for word, pos in tagged_words if pos in keep_pos]
|
138 |
+
|
139 |
+
return filtered_words
|
140 |
+
|
141 |
+
def SepHypandSynExpansion(text):
|
142 |
+
# Tokenize the text
|
143 |
+
tokens = nltk.word_tokenize(text)
|
144 |
+
NoHits = ""
|
145 |
+
FinalOutput = ""
|
146 |
+
|
147 |
+
# Find synonyms and hypernyms of each word in the text
|
148 |
+
for token in tokens:
|
149 |
+
synonyms = []
|
150 |
+
hypernyms = []
|
151 |
+
for synset in wordnet.synsets(token):
|
152 |
+
synonyms += synset.lemma_names()
|
153 |
+
hypernyms += [hypernym.name() for hypernym in synset.hypernyms()]
|
154 |
+
if not synonyms and not hypernyms:
|
155 |
+
NoHits += f"{token} | "
|
156 |
+
else:
|
157 |
+
FinalOutput += "\n" f"{token}: hypernyms={hypernyms}, synonyms={synonyms} \n"
|
158 |
+
NoHits = set(NoHits.split(" | "))
|
159 |
+
NoHits = filter_words(NoHits)
|
160 |
+
NoHits = "Words to pay special attention to: \n" + str(NoHits)
|
161 |
+
return NoHits, FinalOutput
|
162 |
+
|
163 |
+
|
164 |
+
def WikiSearch(term):
|
165 |
+
termtoks = term.split(" ")
|
166 |
+
|
167 |
+
for item in termtoks:
|
168 |
+
# Search for the term on Wikipedia and get the first result
|
169 |
+
result = wikipedia.search(item, results=20)
|
170 |
+
return result
|
171 |
+
|
172 |
+
def create_dictionary(word_list, word_dict = {}):
|
173 |
+
word_list = set(word_list.split(" "))
|
174 |
+
for word in word_list:
|
175 |
+
key = word[:2]
|
176 |
+
if key not in word_dict:
|
177 |
+
word_dict[key] = [word]
|
178 |
+
else:
|
179 |
+
word_dict[key].append(word)
|
180 |
+
return word_dict
|
181 |
+
|
182 |
+
def merge_lines(roman_file, w4w_file, full_mean_file, macaronic_file):
|
183 |
+
files = [roman_file, w4w_file, full_mean_file, macaronic_file]
|
184 |
+
merged_lines = []
|
185 |
+
|
186 |
+
with open(roman_file.name, "r") as f1, open(w4w_file.name, "r") as f2, \
|
187 |
+
open(full_mean_file.name, "r") as f3, open(macaronic_file.name, "r") as f4:
|
188 |
+
for lines in zip(f1, f2, f3, f4):
|
189 |
+
merged_line = "\n".join(line.strip() for line in lines)
|
190 |
+
merged_lines.append(merged_line)
|
191 |
+
|
192 |
+
return "\n".join(merged_lines)
|
193 |
+
|
194 |
+
TTSLangOptions = gr.Dropdown(choices=["en", "de", "es", "ja", "ko", "zh-cn"], value="en", label="choose the language of the srt/text accent")
|
195 |
+
TTSLangOptions2 = gr.Dropdown(choices=["en", "de", "es", "ja", "ko", "zh-cn"], value="en", label="choose the language of the srt/text accent")
|
196 |
+
|
197 |
+
def TTSforListeningPractice(text, language = "en", Repeat10x = False):
|
198 |
+
if Repeat10x:
|
199 |
+
text = text * 10
|
200 |
+
speech = gTTS(text=text, lang=language, slow="False")
|
201 |
+
speech.save("CurrentTTSFile.mp3")
|
202 |
+
#file = BytesIO()
|
203 |
+
#speech.write_to_fp(file)
|
204 |
+
#file.seek(0)
|
205 |
+
return "CurrentTTSFile.mp3" #file
|
206 |
+
|
207 |
+
def AutoChorusInvestigator(sentences):
|
208 |
+
sentences = sentences.splitlines()
|
209 |
+
# Use Counter to count the number of occurrences of each sentence
|
210 |
+
sentence_counts = Counter(sentences)
|
211 |
+
|
212 |
+
# Identify duplicate sentences
|
213 |
+
duplicates = [s for s, count in sentence_counts.items() if count > 1]
|
214 |
+
|
215 |
+
FinalOutput = ""
|
216 |
+
if len(duplicates) == 0:
|
217 |
+
FinalOutput += "No duplicate sentences found in the file."
|
218 |
+
else:
|
219 |
+
FinalOutput += "The following sentences appear more than once in the file:"
|
220 |
+
for sentence in duplicates:
|
221 |
+
FinalOutput += "\n" + sentence
|
222 |
+
return FinalOutput
|
223 |
+
|
224 |
+
def AutoChorusPerWordScheduler(sentences):
|
225 |
+
words = set(sentences.split(" "))
|
226 |
+
wordsoneattime =[]
|
227 |
+
practicestring = ""
|
228 |
+
|
229 |
+
FinalOutput = "This is supposed to output the words in repetition format (i.e. schedule for repitition) \nCurrent Idea = 1 new word every min and 1 old word every second" + "\n\nWords: \n"
|
230 |
+
for word in words:
|
231 |
+
wordsoneattime.append(word)
|
232 |
+
for i in range(0, 59):
|
233 |
+
practicestring += word + " "
|
234 |
+
practicestring += random.choice(wordsoneattime) + " "
|
235 |
+
FinalOutput += word + "\n "
|
236 |
+
practicestring += "\n"
|
237 |
+
|
238 |
+
FinalOutput += practicestring
|
239 |
+
return FinalOutput
|
240 |
+
|
241 |
+
def group_words(inlist):
|
242 |
+
inlisttoks = inlist.split(" ")
|
243 |
+
inlistset = set(inlisttoks)
|
244 |
+
|
245 |
+
word_groups = []
|
246 |
+
current_group = []
|
247 |
+
|
248 |
+
for word in inlisttoks:
|
249 |
+
current_group.append(word)
|
250 |
+
if len(current_group) == 10:
|
251 |
+
word_groups.append(current_group)
|
252 |
+
current_group = []
|
253 |
+
if current_group:
|
254 |
+
word_groups.append(current_group)
|
255 |
+
|
256 |
+
current_group_index = 0
|
257 |
+
current_group_time = 0
|
258 |
+
|
259 |
+
while True:
|
260 |
+
if current_group_time == 60:
|
261 |
+
current_group_index = (current_group_index + 1) % len(word_groups)
|
262 |
+
current_group_time = 0
|
263 |
+
else:
|
264 |
+
if current_group_time % 10 == 0:
|
265 |
+
random.shuffle(word_groups[current_group_index])
|
266 |
+
current_group_time += 10
|
267 |
+
|
268 |
+
yield " ".join(word_groups[current_group_index])
|
269 |
+
time.sleep(10)
|
270 |
+
|
271 |
+
def split_verbs_nouns(text):
|
272 |
+
nlp = spacy.load("en_core_web_sm")
|
273 |
+
doc = nlp(text)
|
274 |
+
|
275 |
+
verbs_nouns = []
|
276 |
+
other_words = []
|
277 |
+
pos_string = []
|
278 |
+
|
279 |
+
for token in doc:
|
280 |
+
if token.pos_ in ["VERB", "NOUN"]:
|
281 |
+
verbs_nouns.append(token.text)
|
282 |
+
elif token.text in [punct.text for punct in doc if punct.is_punct]:
|
283 |
+
verbs_nouns.append(token.text)
|
284 |
+
other_words.append(token.text)
|
285 |
+
else:
|
286 |
+
other_words.append(token.text)
|
287 |
+
pos_string.append(token.pos_)
|
288 |
+
|
289 |
+
verbs_nouns_text = " ".join(verbs_nouns)
|
290 |
+
other_words_text = " ".join(other_words)
|
291 |
+
pos_string_text = " ".join(pos_string)
|
292 |
+
|
293 |
+
return pos_string_text, verbs_nouns_text, other_words_text
|
294 |
+
|
295 |
+
SRTLangOptions = gr.Dropdown(choices=["en", "ja", "ko", "zh-cn"], value="en", label="choose the language of the srt")
|
296 |
+
|
297 |
+
def save_string_to_file(string_to_save, file_name, srtdocx):
|
298 |
+
with open(file_name, 'w', encoding='utf-8') as file:
|
299 |
+
file.write(string_to_save)
|
300 |
+
if srtdocx == "True":
|
301 |
+
with open(file_name.split('.')[0] + '.srt', 'w', encoding='utf-8') as file:
|
302 |
+
file.write(string_to_save)
|
303 |
+
srtdocument = Document()
|
304 |
+
srtdocument.add_paragraph(string_to_save)
|
305 |
+
srtdocument.save('SplitSRT.docx')
|
306 |
+
|
307 |
+
def split_srt_file(text, lang): #file_path):
|
308 |
+
# Open the SRT file and read its contents
|
309 |
+
#with open(file_path, 'r') as f:
|
310 |
+
# srt_contents = f.read()
|
311 |
+
|
312 |
+
if lang == "en": nlp = spacy.load('en_core_web_sm')
|
313 |
+
if lang == "ja": nlp = spacy.load('ja_core_news_sm')
|
314 |
+
if lang == "ko": nlp = spacy.load('ko_core_news_sm')
|
315 |
+
if lang == "zn-cn": nlp = spacy.load('zn_core_web_sm')
|
316 |
+
|
317 |
+
srt_contents = text
|
318 |
+
|
319 |
+
# Split the SRT file by timestamp
|
320 |
+
srt_sections = srt_contents.split('\n\n')
|
321 |
+
srt_sections_POSversion = []
|
322 |
+
subaswordlist = ""
|
323 |
+
|
324 |
+
# Loop through each section of the SRT file
|
325 |
+
for i in range(len(srt_sections)):
|
326 |
+
# Split the section into its timestamp and subtitle text
|
327 |
+
section_lines = srt_sections[i].split('\n')
|
328 |
+
timestamp = section_lines[1]
|
329 |
+
subtitle_text = ' | '.join(section_lines[2:])
|
330 |
+
sub_split_line = nlp(subtitle_text)
|
331 |
+
subtitle_textPOSversion = ""
|
332 |
+
subtitle_text = ""
|
333 |
+
|
334 |
+
# Replace spaces in the subtitle text with " | "
|
335 |
+
#subtitle_text = subtitle_text.replace(' ', ' | ')
|
336 |
+
for token in sub_split_line:
|
337 |
+
subtitle_text += token.text + " | "
|
338 |
+
subaswordlist += token.text + " "
|
339 |
+
subtitle_textPOSversion += token.pos_ + " | "
|
340 |
+
|
341 |
+
# Reconstruct the section with the updated subtitle text
|
342 |
+
srt_sections[i] = f"{section_lines[0]}\n{timestamp}\n{subtitle_text[3:]}"
|
343 |
+
srt_sections_POSversion.append(f"{section_lines[0]}\n{timestamp}\n{subtitle_textPOSversion[3:]}\n\n")
|
344 |
+
|
345 |
+
SplitSRT = '\n\n'.join(srt_sections)
|
346 |
+
SplitPOSsrt = ''.join(srt_sections_POSversion)
|
347 |
+
save_string_to_file(SplitSRT, "SplitSRT.txt", "True")
|
348 |
+
save_string_to_file(SplitPOSsrt, "SplitPOSsrt.txt", "False")
|
349 |
+
subaswordlist = set(subaswordlist.split(" "))
|
350 |
+
subaswordlistOutput = ""
|
351 |
+
|
352 |
+
for word in subaswordlist:
|
353 |
+
subaswordlistOutput += "\n | " + word
|
354 |
+
|
355 |
+
subaswordlistOutput = str(len(subaswordlist)) + "\n" + subaswordlistOutput
|
356 |
+
|
357 |
+
# Join the SRT sections back together into a single string
|
358 |
+
return subaswordlistOutput, ["SplitSRT.docx", "SplitSRT.txt", "SplitSRT.srt", "SplitPOSsrt.txt"], SplitSRT, SplitPOSsrt
|
359 |
+
|
360 |
+
def find_string_positions(s, string):
|
361 |
+
positions = []
|
362 |
+
start = 0
|
363 |
+
while True:
|
364 |
+
position = s.find(string, start)
|
365 |
+
if position == -1:
|
366 |
+
break
|
367 |
+
positions.append(position)
|
368 |
+
start = position + len(string)
|
369 |
+
return positions
|
370 |
+
|
371 |
+
def splittext(string):
|
372 |
+
string_no_formaterror = string.replace(" -- > ", " --> ")
|
373 |
+
split_positions = find_string_positions(string_no_formaterror, " --> ")
|
374 |
+
split_strings = []
|
375 |
+
prepos = 0
|
376 |
+
for pos in split_positions:
|
377 |
+
pos -= 12
|
378 |
+
split_strings.append((string[prepos:pos])) #, string[pos:]))
|
379 |
+
prepos = pos
|
380 |
+
|
381 |
+
FinalOutput = ""
|
382 |
+
stoutput = ""
|
383 |
+
linenumber = 1
|
384 |
+
#print(linenumber)
|
385 |
+
for item in split_strings[1:]:
|
386 |
+
stoutput = item[0:29] + "\n" + item[30:]
|
387 |
+
stspaces = find_string_positions(stoutput, " ")
|
388 |
+
FinalOutput += str(linenumber) + "\n" + stoutput[:stspaces[-2]] + "\n"
|
389 |
+
FinalOutput += "\n"
|
390 |
+
linenumber += 1
|
391 |
+
return FinalOutput[2:]
|
392 |
+
|
393 |
+
def VideotoSegment(video_file, subtitle_file):
|
394 |
+
# Read the subtitle file and extract the timings for each subtitle
|
395 |
+
timings = []
|
396 |
+
for line in subtitle_file:
|
397 |
+
if '-->' in line:
|
398 |
+
start, end = line.split('-->')
|
399 |
+
start_time = start.strip().replace(',', '.')
|
400 |
+
end_time = end.strip().replace(',', '.')
|
401 |
+
timings.append((start_time, end_time))
|
402 |
+
|
403 |
+
# Cut the video into segments based on the subtitle timings
|
404 |
+
video_segments = []
|
405 |
+
for i, (start_time, end_time) in enumerate(timings):
|
406 |
+
output_file = f'segment_{i}.mp4'
|
407 |
+
ffmpeg.input(video_file, ss=start_time, to=end_time).output(output_file, codec='copy').run()
|
408 |
+
video_segments.append(output_file)
|
409 |
+
|
410 |
+
# Convert each segment to an MP3 audio file using FFmpeg
|
411 |
+
audio_segments = []
|
412 |
+
for i in range(len(timings)):
|
413 |
+
output_file = f'segment_{i}.mp3'
|
414 |
+
ffmpeg.input(video_segments[i]).output(output_file, codec='libmp3lame', qscale='4').run()
|
415 |
+
audio_segments.append(output_file)
|
416 |
+
|
417 |
+
# Create a ZIP archive containing all of the segmented files
|
418 |
+
zip_file = zipfile.ZipFile('segmented_files.zip', 'w')
|
419 |
+
for segment in video_segments + audio_segments:
|
420 |
+
zip_file.write(segment)
|
421 |
+
os.remove(segment)
|
422 |
+
zip_file.close()
|
423 |
+
|
424 |
+
# Return the ZIP archive for download
|
425 |
+
return 'segmented_files.zip'
|
426 |
+
|
427 |
+
def text_to_dropdown(text, id=None): #TextCompFormat
|
428 |
+
lines = text.strip().split("\n")
|
429 |
+
html = "<select"
|
430 |
+
if id:
|
431 |
+
html += f' id="{id}"'
|
432 |
+
html += "> \n"
|
433 |
+
for line in lines:
|
434 |
+
html += f" <option>{line}</option>\n"
|
435 |
+
html += "</select> \n"
|
436 |
+
return html
|
437 |
+
|
438 |
+
def text_to_links(text): #TextCompFormat
|
439 |
+
lines = text.strip().split("\n")
|
440 |
+
html = ""
|
441 |
+
for line in lines:
|
442 |
+
if line.startswith("http"):
|
443 |
+
html += f"<a href='{line}'> -- -- </a> | \n"
|
444 |
+
else:
|
445 |
+
html += line + "Not a link <br> \n"
|
446 |
+
return html
|
447 |
+
|
448 |
+
HTMLCompMode = gr.Dropdown(choices=["Dropdown", "Links"], value="Links")
|
449 |
+
|
450 |
+
def TextCompFormat(text, HTMLCompMode):
|
451 |
+
FinalOutput = ""
|
452 |
+
if HTMLCompMode == "Dropdown":
|
453 |
+
FinalOutput = text_to_dropdown(text)
|
454 |
+
if HTMLCompMode == "Links":
|
455 |
+
FinalOutput = text_to_links(text)
|
456 |
+
return FinalOutput
|
457 |
+
|
458 |
+
def create_collapsiblebutton(button_id, button_caption, div_content):
|
459 |
+
button_html = f'<button id="{button_id}" class="accordionbtn">{button_caption}</button>'
|
460 |
+
div_html = f'<div id="{button_id}Div" class="panel">\n{div_content}\n </div>'
|
461 |
+
return button_html + "\n " + div_html
|
462 |
+
|
463 |
+
#---------------
|
464 |
+
|
465 |
+
def removeTonalMarks(string):
|
466 |
+
tonalMarks = "āēīōūǖáéíóúǘǎěǐǒǔǚàèìòùǜɔɛ"
|
467 |
+
nonTonalMarks = "aeiouuaeiouuaeiouuaeiouoe"
|
468 |
+
noTonalMarksStr = ""
|
469 |
+
for char in string:
|
470 |
+
index = tonalMarks.find(char)
|
471 |
+
if index != -1:
|
472 |
+
noTonalMarksStr += nonTonalMarks[index]
|
473 |
+
else:
|
474 |
+
noTonalMarksStr += char
|
475 |
+
return noTonalMarksStr
|
476 |
+
|
477 |
+
|
478 |
+
def add_text_to_image(input_image, text, output_image_path="output.png", border_size=2):
|
479 |
+
text = removeTonalMarks(text)
|
480 |
+
imagearr = np.asarray(input_image) #Image.open(input_image_path)
|
481 |
+
width, height = imagearr.shape[:2] #width, height = image.size
|
482 |
+
img = Image.fromarray(imagearr)
|
483 |
+
draw = ImageDraw.Draw(img)
|
484 |
+
font = ImageFont.truetype("ShortBaby.ttf", 36) #ShortBaby-Mg2w.ttf
|
485 |
+
text_width, text_height = draw.textbbox((0, 0), text, font=font)[2:] #draw.textsize(text, font)
|
486 |
+
# calculate the x, y coordinates of the text box
|
487 |
+
x = (width - text_width) / 2
|
488 |
+
y = (height - text_height) / 2
|
489 |
+
# put the text on the image with a border
|
490 |
+
for dx, dy in [(0, 0), (border_size, border_size), (-border_size, -border_size), (border_size, -border_size), (-border_size, border_size)]:
|
491 |
+
draw.text((x + dx, y + dy), text, font=font, fill=(255, 255, 255))
|
492 |
+
draw.text((x, y), text, font=font, fill=(0, 0, 0))
|
493 |
+
img.save(output_image_path, "PNG")
|
494 |
+
return "output.png"
|
495 |
+
|
496 |
+
def UnknownTrackTexttoApp(text): #Copy of def OptimisedTtAppForUNWFWO(text):
|
497 |
+
#Buttons and labels autocreation
|
498 |
+
#Change this to spacy version so that data is from one library
|
499 |
+
#Javascript videos on youtube - KodeBase - Change button color Onclick; bro code - button in 5 minutes
|
500 |
+
#GPT3 helped guide the highlighting if statements
|
501 |
+
|
502 |
+
FinalOutput = ""
|
503 |
+
#sentence = "One Piece chapter 1049 spoilers Thanks to Etenboby from WG forums Chapter 1049: **\"The world we should aspire to\"** * In the cover, someone burned Niji and Yonji\u2019s book * Kaido flashback time. We see his childhood in Vodka Kingdom, and where a few years later he met Whitebeard who told him that Rocks wants to meet him * In the present, part of Raizo\u2019s water leaves the castle and flame clouds disappear. But Momo makes a new one. * Luffy says he will create a world where none of his friends would starve, then he hits Kaido and Kaido falls to the ground of the flower capital. * In another flashback, Kaido tells King that Joy Boy will be the man that can defeat him. **Additional info** *Flashback to Kaidou as a kid* *- His country tries to sell him to the marines but he escapes* *- He rampages in Hachinosu(i think it's blackbeard's island) and Rocks invites him to his crew* *- Young WB appears* *- Rocks flashback suddenly ends* *- Higurashi invites Kaidou* *- The flashback ends with Kaidou telling King he knows who Joy Boy is.* *Back to the present* \\- *Denjirou hugs Hiyori* \\- *Luffy's punch hits Kaidou* *Flashback continues* \\- *King asks: Who is it then?* \\- *Kaidou: The one who will defeat me* \\- *King: Then he will not appear* \\- *Onigashima falls near the capital* \\- *Momo falls* **BREAK NEXT WEEK** https://www.reddit.com/r/OnePiece/comments/umu2h0/one_piece_chapter_1049_spoilers/" #@param {type: "string"}
|
504 |
+
HTMLMainbody = ""
|
505 |
+
|
506 |
+
doc = nlp(text)
|
507 |
+
iIDNumber = 0
|
508 |
+
iVerbCount = 0
|
509 |
+
iNounCount = 0
|
510 |
+
iWords = 0
|
511 |
+
allverbs = ""
|
512 |
+
allverbslist = ""
|
513 |
+
allverbids = ""
|
514 |
+
allverbidslist = ""
|
515 |
+
|
516 |
+
for token in doc:
|
517 |
+
if (token.pos_ == "VERB") or (token.pos_ == "AUX"):
|
518 |
+
HTMLMainbody = HTMLMainbody + "<button id='btn" + str(iVerbCount) + "' onclick=HighlightWord('btn" + str(iVerbCount) + "')> " + token.text + "</button> "
|
519 |
+
allverbids = allverbids + str(iVerbCount) + " "
|
520 |
+
iVerbCount += 1
|
521 |
+
iWords += 1
|
522 |
+
allverbs = allverbs + token.text + " "
|
523 |
+
elif token.pos_ == "NOUN":
|
524 |
+
HTMLMainbody = HTMLMainbody + "<label class='Nouns' id='lbl" + token.text + "'>" + token.text + " </label>"
|
525 |
+
iNounCount += 1
|
526 |
+
iWords += 1
|
527 |
+
elif token.pos_ == "PUNCT":
|
528 |
+
HTMLMainbody = HTMLMainbody + token.text
|
529 |
+
else:
|
530 |
+
HTMLMainbody = HTMLMainbody + token.text + " "
|
531 |
+
iWords += 1
|
532 |
+
iIDNumber += 1
|
533 |
+
|
534 |
+
allverbslist = allverbs.split()
|
535 |
+
allverbidslist = allverbids.split()
|
536 |
+
|
537 |
+
FinalHTML = ""
|
538 |
+
FinalCSS = ""
|
539 |
+
FinalJS = ""
|
540 |
+
|
541 |
+
FinalCSS = FinalCSS + ''' <style>
|
542 |
+
body {
|
543 |
+
background-color: darksalmon;
|
544 |
+
}
|
545 |
+
|
546 |
+
.Nouns {
|
547 |
+
color: red;
|
548 |
+
}
|
549 |
+
|
550 |
+
.clunknown{
|
551 |
+
background-color: gainsboro;
|
552 |
+
}
|
553 |
+
|
554 |
+
.clknownl1{
|
555 |
+
background-color: yellow;
|
556 |
+
}
|
557 |
+
|
558 |
+
.clknownl2{
|
559 |
+
background-color: gold;
|
560 |
+
}
|
561 |
+
|
562 |
+
.clknownl3{
|
563 |
+
background-color: orange;
|
564 |
+
}
|
565 |
+
|
566 |
+
.PD1 {
|
567 |
+
text-align: center;
|
568 |
+
font-size: larger;
|
569 |
+
font-family: cursive;
|
570 |
+
}
|
571 |
+
|
572 |
+
.PD2 {
|
573 |
+
font-family: monospace;
|
574 |
+
}
|
575 |
+
</style>
|
576 |
+
'''
|
577 |
+
|
578 |
+
#style='background-color:Gainsboro; There is no general style attribute for buttons but you can make a class and put the style conditions
|
579 |
+
|
580 |
+
iSents = 0
|
581 |
+
for sent in doc.sents:
|
582 |
+
iSents += 1
|
583 |
+
|
584 |
+
FinalHTML = FinalHTML + "\n<div id='PD1'>Picture on mouse hover = Visual<br> Speed = End Goal ==> App Timer Functions ||| \nSentences: " + str(iSents) + " | Words: " + str(iWords) + " | App elements: " + str(iNounCount + iVerbCount) + " | Verbs: " + str(iVerbCount) + "</div>"
|
585 |
+
FinalHTML = FinalHTML + "\n<div><hr><progress id='myVerbProgress' value='0' max='" + str(iVerbCount) + "'></progress></div>"
|
586 |
+
FinalJS = FinalJS + '''\n
|
587 |
+
<script>
|
588 |
+
function HighlightWord(Button){
|
589 |
+
if (document.getElementById(Button).style.backgroundColor === 'orange') {
|
590 |
+
document.getElementById(Button).style.backgroundColor=''
|
591 |
+
}
|
592 |
+
else if (document.getElementById(Button).style.backgroundColor === 'gold') {
|
593 |
+
document.getElementById(Button).style.backgroundColor='orange'
|
594 |
+
}
|
595 |
+
else if (document.getElementById(Button).style.backgroundColor === 'yellow') {
|
596 |
+
document.getElementById(Button).style.backgroundColor='gold'
|
597 |
+
}
|
598 |
+
else {document.getElementById(Button).style.backgroundColor='yellow'
|
599 |
+
}
|
600 |
+
OnlyUnknownVerbs()
|
601 |
+
}
|
602 |
+
'''
|
603 |
+
|
604 |
+
FinalHTML = FinalHTML + "\n<div><hr>\n" + HTMLMainbody + "\n"
|
605 |
+
#FinalHTML = FinalHTML + '''</div><hr>
|
606 |
+
#<button onclick=OnlyUnknownSentences() id="btnOnlyUnknownSentences">Only Unknown Sentences Put this function in a timer to keep up to date without input</button>
|
607 |
+
#'''
|
608 |
+
FinalJS = FinalJS + '''
|
609 |
+
function OnlyUnknownVerbs(){
|
610 |
+
AllButtons = ''' + str(allverbidslist) + '''
|
611 |
+
AllButtonsText = ''' + str(allverbslist) + '''
|
612 |
+
UnknownOutput = ""
|
613 |
+
iUnknownCount = 0
|
614 |
+
AllButtons.forEach(function(item){
|
615 |
+
if (document.getElementById('btn'+item).style.backgroundColor === ''){
|
616 |
+
UnknownOutput += AllButtonsText[item] + " "
|
617 |
+
iUnknownCount += 1
|
618 |
+
}
|
619 |
+
document.getElementById('myVerbProgress').value = ''' + str(iVerbCount) + ''' - iUnknownCount
|
620 |
+
})
|
621 |
+
document.getElementById('PD2').textContent = 'Only Unknwon words list: ' + UnknownOutput
|
622 |
+
}
|
623 |
+
|
624 |
+
|
625 |
+
</script>
|
626 |
+
'''
|
627 |
+
|
628 |
+
FinalHTML = FinalHTML + '''<br><hr><br>
|
629 |
+
<div id='PD2'> Only Unknown List</div>
|
630 |
+
\n
|
631 |
+
'''
|
632 |
+
|
633 |
+
FinalOutput = FinalHTML + FinalCSS + FinalJS
|
634 |
+
|
635 |
+
HTMLDownloadTemp = f'UnknownVerbTrack.html'
|
636 |
+
|
637 |
+
with open(HTMLDownloadTemp, 'w') as f:
|
638 |
+
f.write(FinalOutput)
|
639 |
+
|
640 |
+
return FinalOutput, FinalOutput, HTMLDownloadTemp
|
641 |
+
|
642 |
+
#Kathryn Lingel - Pyambic Pentameter Example - PyCon US
|
643 |
+
#Basic Language Model Code
|
644 |
+
def build_model(source_text):
|
645 |
+
list_of_words = source_text.split()
|
646 |
+
model = {} #initialise model to empty dictionary
|
647 |
+
|
648 |
+
for i, word in enumerate(list_of_words[:-1]): #every word except last word
|
649 |
+
if not word in model: #If word not already in dictionary as a key we add it and initialise to empty array
|
650 |
+
model[word] = []
|
651 |
+
next_word = list_of_words[i+1]
|
652 |
+
model[word].append(next_word) #model = dictionary per word containing previously seen next words from ANY given text ==> even lyrics
|
653 |
+
|
654 |
+
translatestring = str(model)
|
655 |
+
translatestring = translatestring.replace("'", "")
|
656 |
+
return model, translatestring
|
657 |
+
|
658 |
+
def markov_generate(source_text, num_words = 20):
|
659 |
+
model = build_model(source_text)
|
660 |
+
seed = random.choice(list(model.keys())) #Randomly pick a word ==> Heading of the dictionary are keys aka the words
|
661 |
+
output = [seed] #output initialisation using random word
|
662 |
+
for i in range(num_words):
|
663 |
+
last_word = output[-1] #of the output list
|
664 |
+
next_word = random.choice(model[last_word]) # next word to the above word
|
665 |
+
output.append(next_word) #new last word in the output list
|
666 |
+
if next_word not in model:
|
667 |
+
break
|
668 |
+
|
669 |
+
return ' '.join(output) #New list into a string aka (hopefully) sentence
|
670 |
+
# print(markov_generate("I am the egg man they are the egg men I am the wallrus goo goo g' joob"))
|
671 |
+
|
672 |
+
def chunk_srt_text(srt_text, chunk_size):
|
673 |
+
# Split the SRT text into chunks of the specified size
|
674 |
+
ChunkList = textwrap.wrap(srt_text, chunk_size)
|
675 |
+
dfFinalOutput = pd.DataFrame(ChunkList, columns = [f"Chunks - { len(ChunkList) }"])
|
676 |
+
return dfFinalOutput, ""
|
677 |
+
|
678 |
+
#-------------------------------------------------------------------------------------------------------------------------------
|
679 |
+
#Clean Merge
|
680 |
+
|
681 |
+
def split_into_fours(text):
|
682 |
+
lines = text.split('\n')
|
683 |
+
chunks = [lines[i:i+4] for i in range(0, len(lines), 4)]
|
684 |
+
return chunks
|
685 |
+
|
686 |
+
def NumberLineSort(listlen):
|
687 |
+
numbers = list(range(0, listlen)) # create a list of numbers 1 to 12
|
688 |
+
grouped_numbers = []
|
689 |
+
for i in range(4):
|
690 |
+
group = [numbers[j] for j in range(i, len(numbers), 4)]
|
691 |
+
grouped_numbers.append(group)
|
692 |
+
return grouped_numbers
|
693 |
+
|
694 |
+
def SRTLineSort(text):
|
695 |
+
chunks = split_into_fours(text)
|
696 |
+
NumberofBlocks = len(chunks) / 4
|
697 |
+
printnumber = NumberLineSort(len(chunks))
|
698 |
+
SRTLinenumber = []
|
699 |
+
SRTTiming = []
|
700 |
+
SRTContent = []
|
701 |
+
FinalOutput = ""
|
702 |
+
|
703 |
+
for i in range(0, 3):
|
704 |
+
for item in printnumber[i]:
|
705 |
+
if i == 0: SRTLinenumber.append(chunks[item][0])
|
706 |
+
if i == 1: SRTTiming.append(chunks[item][0])
|
707 |
+
if i == 2: SRTContent.append(chunks[item])
|
708 |
+
|
709 |
+
for i in range(0, int(NumberofBlocks)):
|
710 |
+
FinalOutput += SRTLinenumber[i] + "\n"
|
711 |
+
FinalOutput += SRTTiming[i] + "\n"
|
712 |
+
for i2 in range(0, 4):
|
713 |
+
FinalOutput += SRTContent[i][i2] + "\n"
|
714 |
+
FinalOutput += "\n"
|
715 |
+
|
716 |
+
return FinalOutput
|
717 |
+
|
718 |
+
#--------------------------------------------------------------------------------------------------------------------------------
|
719 |
+
|
720 |
+
RandomiseTextType = gr.Dropdown(choices=["Words", "Words5x", "Sentences", "Paragraph", "Page"], value="Words")
|
721 |
+
|
722 |
+
def RandomiseTextbyType(Text, Choice):
|
723 |
+
FinalOutput = ""
|
724 |
+
TempWords = []
|
725 |
+
|
726 |
+
if Choice == "Words" :
|
727 |
+
TempWords = Text.split()
|
728 |
+
FinalOutput = reading_randomize_words(TempWords)
|
729 |
+
if Choice == "Words5x" :
|
730 |
+
TempWords = Text.split()
|
731 |
+
FinalOutput = reading_randomize_words5x(TempWords)
|
732 |
+
if Choice == "Sentences" : FinalOutput = reading_randomize_words_in_sentence(Text)
|
733 |
+
if Choice == "Paragraph" : FinalOutput = reading_randomize_words_in_paragraph(Text)
|
734 |
+
if Choice == "Page" : FinalOutput = "Still under Construction"
|
735 |
+
|
736 |
+
return FinalOutput
|
737 |
+
|
738 |
+
def reading_randomize_words5x(word):
|
739 |
+
wordScram = ""
|
740 |
+
for item in word:
|
741 |
+
for i in range(5):
|
742 |
+
item = ''.join(random.sample(item, len(item)))
|
743 |
+
wordScram += " " + item
|
744 |
+
#print(item)
|
745 |
+
wordScram += "\n"
|
746 |
+
return wordScram
|
747 |
+
|
748 |
+
def reading_randomize_words(word):
|
749 |
+
wordScram = ""
|
750 |
+
for item in word:
|
751 |
+
item = ''.join(random.sample(item, len(item)))
|
752 |
+
wordScram += item + " "
|
753 |
+
return wordScram
|
754 |
+
|
755 |
+
def reading_randomize_words_in_sentence(text):
|
756 |
+
FinalOutput = ""
|
757 |
+
sentences = text.split(".")
|
758 |
+
for sentence in sentences:
|
759 |
+
words = sentence.split()
|
760 |
+
random.shuffle(words)
|
761 |
+
FinalOutput += ' '.join(words) + ". "
|
762 |
+
return FinalOutput
|
763 |
+
|
764 |
+
def reading_randomize_words_in_paragraph(paragraph):
|
765 |
+
sentences = paragraph.split(".")
|
766 |
+
random.shuffle(sentences)
|
767 |
+
return '. '.join(sentences)
|
768 |
+
|
769 |
+
def changeexposuretext(text):
|
770 |
+
return f"<marquee> {text} </marquee>"
|
771 |
+
|
772 |
+
#-------------------------------------------------------------------------------------------------------------------------------
|
773 |
+
|
774 |
+
def arrealtimetestidea(img):
|
775 |
+
return "Unfinished. The aim is to do realtime translation google but based on knowledge domains instead of language - Look at HF Models and spaces"
|
776 |
+
|
777 |
+
#------------------------------------------------------------------------------------------------------------------------------
|
778 |
+
|
779 |
+
|
780 |
+
LLPromptIdeas = """
|
781 |
+
|
782 |
+
<p> Make jokes while following rules for a syllogism jokes game:
|
783 |
+
|
784 |
+
The game can be played with any number of people.
|
785 |
+
One person starts by stating a syllogism, which is a logical argument that consists of three parts: a major premise, a minor premise, and a conclusion.
|
786 |
+
The next person must then state a syllogism that has the same conclusion as the first syllogism, but with different major and minor premises.
|
787 |
+
The game continues in this way until someone cannot think of a new syllogism.
|
788 |
+
The person who makes the last valid syllogism wins the game. </p>
|
789 |
+
|
790 |
+
<hr>
|
791 |
+
|
792 |
+
<p> Lets try this I will give you the english word and you find the <<chinese>> word and then mix the meaning of the word with the mnemonic </>
|
793 |
+
|
794 |
+
Bings Explanation
|
795 |
+
Youre welcome. Im happy to help. If I wanted to explain the rules of this game clearly and concisely, I would do something like this:
|
796 |
+
|
797 |
+
The game is about finding the <<Chinese>> word for an English word and making a mnemonic that mixes the meaning of the word with the mnemonic.
|
798 |
+
The game has two players: one who gives the English word and one who finds the <<Chinese>> word and makes the mnemonic.
|
799 |
+
The player who gives the English word can choose any word they want, as long as it has a <<Chinese>> equivalent.
|
800 |
+
The player who finds the <<Chinese>> word and makes the mnemonic can use any online or offline resources they want, such as dictionaries, translators, or search engines.
|
801 |
+
The player who finds the <<Chinese>> word and makes the mnemonic should write their answer in the format: The <<Chinese>> word for X is Y <<(pinyin)>>, which means Z. Here are some possible mnemonics that mix the meaning of the word with the mnemonic: A, B, C, D. </p>
|
802 |
+
"""
|
803 |
+
|
804 |
+
|
805 |
+
# Define the Gradio interface inputs and outputs for video split
|
806 |
+
spvvideo_file_input = gr.File(label='Video File')
|
807 |
+
spvsubtitle_file_input = gr.File(label='Subtitle File')
|
808 |
+
spvdownload_output = gr.File(label='Download Segmented Files')
|
809 |
+
|
810 |
+
Markovlength = gr.Number(value=30, label='Length of generation')
|
811 |
+
|
812 |
+
groupinput_text = gr.Textbox(lines=2, label="Enter a list of words")
|
813 |
+
groupoutput_text = gr.Textbox(label="Grouped words")
|
814 |
+
|
815 |
+
Translationchuncksize = gr.Number(value=4998)
|
816 |
+
|
817 |
+
randomExposuremessagelistitem = str(random.sample(["Bing mnemonic - lost = dont ignore unusual sounds here inside lost cave", "1000 verbs in lists of 100, verbs = easy setence structure estimation (SVO, SOV, etc.)", "Can put any message here in the navigatoin tab"], 1)).replace("['", "").replace("']", "")
|
818 |
+
randomExposuremessage = f" <marquee> { randomExposuremessagelistitem } </marquee> "
|
819 |
+
|
820 |
+
|
821 |
+
|
822 |
+
with gr.Blocks() as lliface: #theme=gr.themes.Glass(primary_hue='green', secondary_hue='red', neutral_hue='blue', )
|
823 |
+
PracticeExposure = gr.HTML(randomExposuremessage)
|
824 |
+
gr.HTML("Advanced Repitition = Combinatorics --> to understand a sentence properly you need understanding of every word --> in language that means use with other words --> Combos within the unique words in a sentence, paragraph, page, etc. --> as close to 3 word sentences")
|
825 |
+
gr.HTML("<p>Timing Practice - Repitition: Run from it, Dread it, Repitition is inevitable - Thanos --> Repitition of reaction - Foreign in eyes/ears native in mind (For beginners) | Repitition is a multitask activity like driving must be subconcious process to show mastery </p>")
|
826 |
+
gr.HTML(""" <a href='https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard'> -- Open LLM Leaderboard -- </a> | <a href='https://huggingface.co/spaces/sanchit-gandhi/whisper-jax'> -- Whisper JAX -- </a> | <a href="https://translate.google.com/?hl=en&tab=TT"> -- Google Translate -- </a> | <a href='https://huggingface.co/spaces/damo-vilab/modelscope-text-to-video-synthesis'> -- Modelscope Text to Video -- </a> | <a href='https://huggingface.co/spaces/stabilityai/stable-diffusion'> -- stable-diffusion 2 -- </a> | <a href='https://huggingface.co/spaces/stabilityai/stable-diffusion-1'> -- stable-diffusion 1 -- </a> | <a href='https://huggingface.co/spaces/kakaobrain/karlo'> -- karlo 1 -- </a> | <a href='https://huggingface.co/spaces/suno/bark'> -- Bark (TTS) -- </a> | <a href='https://chat.lmsys.org/'> -- Offline Text Model Demos -- </a> | <a href='https://huggingface.co/spaces/curt-park/segment-anything-with-clip'> -- SAM with Clip -- </a> | <a href='https://beta.elevenlabs.io/'> -- Eleven Labs -- </a> | <a href='https://www.d-id.com/'> -- Animate an Image -- </a> | <a href='https://voice.ai/'> -- Clone a voice -- </a> | <a href='https://openai.com/pricing'> -- OpenAI pricing -- </a> | <a href='https://huggingface.co/spaces/sohojoe/soho-clip-embeddings-explorer'> -- Image Training Data Search -- </a> | <a href='https://huggingface.co/spaces/huggingchat/chat-ui'> -- Huggingface Chat -- </a> | <a href='https://huggingface.co/spaces/bguisard/stable-diffusion-nano'> -- 128x128 Stable Diffusion (Fast) -- </a> | <a href='https://huggingface.co/spaces/colonelwatch/abstracts-index'> -- Search 95 million research abstracts -- </a> | <a href='https://huggingface.co/datasets/roneneldan/TinyStories'> -- Tiny Stories Dataset -- </a> | <a href='https://huggingface.co/spaces/lykeven/visualglm-6b'> -- Visualglm6b - Discuss images -- </a> | <a href='https://huggingface.co/spaces/xinyu1205/Recognize_Anything-Tag2Text'> -- RAM and Tag2Text -- </a> | <a href='https://huggingface.co/camenduru/potat1'> -- Potat1 Text2vid -- </a> | """)
|
827 |
+
with gr.Row():
|
828 |
+
with gr.Column(scale=1):
|
829 |
+
with gr.Tab("Rep - Gradio"):
|
830 |
+
gr.HTML("""Gradio Version Below <iframe height="1200" style="width: 100%;" scrolling="no" title="Memorisation Aid" src="https://codepen.io/kwabs22/embed/GRXKQgj?default-tab=result&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
|
831 |
+
See the Pen <a href="https://codepen.io/kwabs22/pen/GRXKQgj"> Memorisation Aid</a> by kwabs22 (<a href="https://codepen.io/kwabs22">@kwabs22</a>) on <a href="https://codepen.io">CodePen</a>. </iframe>""")
|
832 |
+
with gr.Tab("Rep - Gradio"):
|
833 |
+
gr.Interface(fn=group_words, inputs=groupinput_text, outputs=groupoutput_text, description="Word Grouping and Rotation - Group a list of words into sets of 10 and rotate them every 60 seconds.") #.queue()
|
834 |
+
with gr.Tab("Navigation"):
|
835 |
+
gr.HTML("Picture Annotation <br> Chorus Focused Word List <br> Merged Subtitles <br> Repetitive Audio (TTS) <br> Word and Sentence Jumbling <br> Unkown: Wordnet <br> Unknown: Wikipeadia <br>")
|
836 |
+
PracticeExposureInput = gr.Textbox(placeholer="Exposure practice = look up", label="Exposure at the top")
|
837 |
+
PracticeExposurebtn = gr.Button("Change Default")
|
838 |
+
PracticeExposurebtn.click(fn=changeexposuretext, inputs=PracticeExposureInput, outputs=PracticeExposure)
|
839 |
+
with gr.Tab("Vector Database = Memorisation"):
|
840 |
+
gr.HTML("Open AI - 2500000 character text = <1$ (0.0004 per 1000 tokens), Cohere Multilingual = free for personal use / Commercial use = \n Vector Database query = Better than text search but not for logical relationships")
|
841 |
+
with gr.Column(scale=3):
|
842 |
+
with gr.Tab("Beginner - Listen + Read"):
|
843 |
+
with gr.Row():
|
844 |
+
with gr.Column(scale=1):
|
845 |
+
gr.HTML("Listening - Songs - Chorus <br> Anticipation of the item to remember is how you learn lyrics that is why songs are easy as if you heard it 10 times already your capacity to anticipate the words is great <br><br> This is where TTS helps as you are ignoring all words except the words just before the actual <br> <b>Tiny Stories dataset is like a graded reader</b> <br>")
|
846 |
+
gr.Interface(fn=TTSforListeningPractice, inputs=["text", TTSLangOptions, "checkbox"], outputs="audio", description="Paste chorus lyrics from below here and use TTS or make notes to save here (Or paste anything)")
|
847 |
+
gr.HTML("<p>Fastest way to learn words = is to have your own sound reference --> probably why babies learn fast as they make random noise</p> <p>If you know the flow of the song you can remember the spelling easier</p><p>Essentially if the sounds are repeated or long notes they are easy to remember</p>")
|
848 |
+
gr.Interface(fn=AutoChorusInvestigator, inputs="text", outputs="text", description="Paste Full Lyrics to try find only chorus lines")
|
849 |
+
gr.Interface(fn=AutoChorusPerWordScheduler, inputs="text", outputs="text", description="Create order of repitition for tts practice")
|
850 |
+
with gr.Column(scale=1):
|
851 |
+
gr.HTML("""Reading - Caption images (SD/Dalle-E) <br> <a href='https://unsplash.com/'> -- Unsplash - free images -- </a> | <a href="https://huggingface.co/spaces/pharma/CLIP-Interrogator"> --Huggingface CLIP-Interrogator Space-- </a> | <a href='https://huggingface.co/spaces/xinyu1205/Recognize_Anything-Tag2Text'> -- Tag2Text is faster than clip -- </a> | <br> <a href='https://huggingface.co/spaces/bkhmsi/Word-To-Image'> -- Transform word to an image -- </a> | <a href='https://huggingface.co/spaces/microsoft/Promptist'> -- Promptist (Microsoft) -- </a> | """)
|
852 |
+
gr.Interface(fn=add_text_to_image , inputs=["image", "text"], outputs="image", description="Create Annotated images (Can create using stable diffusion and use the prompt) - Describe from one side to the other to make guessing easy")
|
853 |
+
gr.HTML("Use Shift Enter To put text on new lines if the text doesnt fit <br> if theres an error you have to remove the foreign letters and place roman ones")
|
854 |
+
#with gr.Tab("Transcribe - RASMUS Whisper"):
|
855 |
+
#gr.Interface.load("spaces/RASMUS/Whisper-youtube-crosslingual-subtitles", title="Subtitles")
|
856 |
+
with gr.Tab("Advanced - LingQ Addon Ideas"):
|
857 |
+
gr.HTML("<a href='https://www.lingq.com/en/'>Find LingQ Here --> https://www.lingq.com/en/</a>")
|
858 |
+
with gr.Tab("Visual - Multiline Custom Video Subtitles"):
|
859 |
+
gr.HTML("LingQ Companion Idea - i.e. Full Translation Read along, and eventually Videoplayer watch along like RAMUS whisper space <br><br>Extra functions needed - Persitent Sentence translation, UNWFWO, POS tagging and Word Count per user of words in their account. Macaronic Text is also another way to practice only the important information")
|
860 |
+
gr.HTML("""<hr> <p>For Transcripts to any video on youtube use the link below ⬇️</p> <a href="https://huggingface.co/spaces/RASMUS/Whisper-youtube-crosslingual-subtitles">https://huggingface.co/spaces/RASMUS/Whisper-youtube-crosslingual-subtitles</a> | <a href="https://huggingface.co/spaces/vumichien/whisper-speaker-diarization">https://huggingface.co/spaces/vumichien/whisper-speaker-diarization</a>""")
|
861 |
+
#gr.HTML("<p>If Space not loaded its because of offline devopment errors please message for edit</p> <hr>")
|
862 |
+
with gr.Tab("Merged Subtitles"):
|
863 |
+
gr.HTML(""" Core Idea = Ability to follow one video from start to finish is more important than number of words (except for verbs) <hr>
|
864 |
+
Step 1 - Get foreign transcript - WHISPER (Need to download video though - booo) / Youtube / Youtube transcript api / SRT websites <br>
|
865 |
+
Step 2 - Get Translation of foreign transcript <br>
|
866 |
+
Step 3 - Word for Word Translation Creation in both Directions (Paste Google Translation here) <br>
|
867 |
+
""")
|
868 |
+
gr.Interface(fn=split_srt_file, inputs=["text", SRTLangOptions] , outputs=["text", "file", "text", "text"], description="SRT Contents to W4W Split SRT for Google Translate")
|
869 |
+
gr.Interface(fn=chunk_srt_text, inputs=['text', Translationchuncksize], outputs=['dataframe','text'], description='Assitant for google translate character limit - aka where to expect cuts in the text')
|
870 |
+
gr.HTML("Step 4 - Pronounciation (Roman) to Subtitle Format --> GTranslate returns unformatted string")
|
871 |
+
gr.Interface(fn=splittext, inputs="text", outputs="text", description="Text for w4w creation in G Translate")
|
872 |
+
gr.HTML("Step 5 - Merge into one file")
|
873 |
+
with gr.Row():
|
874 |
+
RomanFile = gr.File(label="Paste Roman")
|
875 |
+
W4WFile = gr.File(label="Paste Word 4 Word")
|
876 |
+
FullMeanFile = gr.File(label="Paste Full Meaning")
|
877 |
+
MacaronicFile = gr.File(label="Paste Macaronic Text")
|
878 |
+
SentGramFormula = gr.File(label="Paste Sentence Grammar Formula Text")
|
879 |
+
with gr.Row():
|
880 |
+
MergeButton = gr.Button(label='Merge the seperate files into one interpolated file (Line by line merge)')
|
881 |
+
with gr.Row():
|
882 |
+
MergeOutput = gr.TextArea(label="Output")
|
883 |
+
MergeButton.click(merge_lines, inputs=[RomanFile, W4WFile, FullMeanFile, MacaronicFile], outputs=[MergeOutput], )
|
884 |
+
with gr.Row():
|
885 |
+
gr.Text("Make sure there are 4 spaces after the last subtitle block (Otherwise its skipped)")
|
886 |
+
CleanedMergeButton = gr.Button(label='Create a Usable file for SRT')
|
887 |
+
with gr.Row():
|
888 |
+
CleanedMergeOutput = gr.TextArea(label="Output")
|
889 |
+
CleanedMergeButton.click(fn=SRTLineSort, inputs=[MergeOutput], outputs=[CleanedMergeOutput])
|
890 |
+
with gr.Tab("Split video to segments"):
|
891 |
+
gr.HTML("<a href='https://www.vlchelp.com/automated-screenshots-interval/'>How to make screenshot in vlc - https://www.vlchelp.com/automated-screenshots-interval/</a><br>")
|
892 |
+
gr.Interface(VideotoSegment, inputs=[spvvideo_file_input, spvsubtitle_file_input], outputs=spvdownload_output)
|
893 |
+
gr.Text("Text to Closed Class + Adjectives + Punctuation or Noun Verb + Punctuation ")
|
894 |
+
with gr.Tab("Audio - Only English thoughts as practice"):
|
895 |
+
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")
|
896 |
+
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")
|
897 |
+
with gr.Tab("Transition is the end goal"):
|
898 |
+
with gr.Row():
|
899 |
+
with gr.Column():
|
900 |
+
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)
|
901 |
+
gr.Interface(fn=RandomiseTextbyType, inputs=["text", RandomiseTextType], outputs="text", description="Randomise order within words, sentences, paragrahs")
|
902 |
+
with gr.Column():
|
903 |
+
#with gr.Tab("Collocations (Markov)"):
|
904 |
+
gr.HTML("Transition is the true nature of logic i.e. like some form of non-semantic embedding that is semantic?")
|
905 |
+
gr.Interface(fn=build_model, inputs="text", outputs=["text", "text"], description="Create Collocation Dictionary --> Google Kathryn Lingel - Pyambic Pentameter Example - PyCon US for more")
|
906 |
+
gr.Interface(fn=markov_generate, inputs=["text", Markovlength], outputs="text", description="Generate Text based on the collocations in the text")
|
907 |
+
with gr.Column():
|
908 |
+
#with gr.Tab("Spelling + Chunks"):
|
909 |
+
gr.Textbox("Merged Spelling Practice Placeholder - Spell multiple words simultaneously for simultaneous access", lines=3)
|
910 |
+
gr.HTML("<p> Spell multiple words simultaneously for simultaneous access </p> <p> Spelling Simplification - Use a dual language list? | Spelling is the end goal, you already know many letter orders called words so you need leverage them to remember random sequences")
|
911 |
+
gr.Interface(fn=create_dictionary, inputs="text", outputs="text", title="Sort Text by first two letters")
|
912 |
+
gr.Interface(fn=keep_nouns_verbs, inputs=["text"], outputs="text", description="Noun and Verbs only (Plus punctuation)")
|
913 |
+
gr.Interface(fn=FrontRevSentChunk, inputs=[ChunkModeDrop, "checkbox", "text", langdest], outputs="text", description="Chunks creator")
|
914 |
+
with gr.Tab("Unknown Tracker"):
|
915 |
+
gr.HTML("Repitition of things you know is a waste of time when theres stuff you dont know <p> In Language the goal is bigger vocab --> Knowledge equivalent = question answer pairs but to get to those you need related information pairs</p> <p> Vocab = Glossary + all non text wall(lists, diagrams, etc.)</p>")
|
916 |
+
gr.Textbox("Placeholder for a function that creates a set list and can takes a list for known words and auto find replaces the stuff you know out of the content")
|
917 |
+
gr.Textbox("Place holder for a translate to english interface so that highlighting can still work as only english supported for now")
|
918 |
+
gr.Interface(fn=UnknownTrackTexttoApp, inputs="text", outputs=["html", "text", "file"], description="Use the text from here to create lists you use for the TTS section")
|
919 |
+
with gr.Tab("Unique word ID - use in Infranodus"):
|
920 |
+
gr.Interface(fn=unique_word_count, inputs="text", outputs="text", description="Wordcounter")
|
921 |
+
gr.Interface(fn=SepHypandSynExpansion, inputs="text", outputs=["text", "text"], description="Word suggestions - Analyse the unique words in infranodus")
|
922 |
+
gr.Interface(fn=WikiSearch, inputs="text", outputs="text", description="One word at a time Unique word suggestions (wiki articles)")
|
923 |
+
with gr.Tab("Automating related information linking"):
|
924 |
+
gr.HTML("Questions - Tacking and suggesting questions to ask = new education")
|
925 |
+
with gr.Tab("Thinking Practice"):
|
926 |
+
with gr.Tab("Sentence to Format"):
|
927 |
+
gr.Interface(fn=split_verbs_nouns , inputs="text", outputs=["text", "text", "text"], description="Comprehension reading and Sentence Format Creator")
|
928 |
+
with gr.Tab("Knowledge Ideas - Notetaking"):
|
929 |
+
gr.HTML("""<p>Good knowledge = ability to answer questions --> find Questions you cant answer and look for hidden answer within them </p>
|
930 |
+
<p>My One Word Theory = We only use more words than needed when we have to or are bored --> Headings exist because title is not sufficient, subheadings exist because headings are not sufficient, Book Text exists because subheadings are not sufficient</p>
|
931 |
+
<p>Big Picture = Expand the Heading and the subheadings and compare them to each other</p>
|
932 |
+
<p>Application of Knowledge = App Version of the text (eg. Jupyter Notebooks) is what you create and learn first</p>
|
933 |
+
""")
|
934 |
+
gr.Interface(fn=TextCompFormat, inputs=["textarea", HTMLCompMode], outputs="text", description="Convert Text to HTML Dropdown or Links which you paste in any html file")
|
935 |
+
gr.Interface(fn=create_collapsiblebutton, inputs=["textbox", "textbox", "textarea"], outputs="textarea", description="Button and Div HTML Generator, Generate the HTML for a button and the corresponding div element.")
|
936 |
+
with gr.Tab("Automated Reading Assitant"):
|
937 |
+
gr.Textbox('Parts of Speech based | Automating the Notetaking Tab either directly or using visual llm to use this interface efficiently')
|
938 |
+
gr.HTML("Types of comprehension agent <hr> Speed of Comprehension = Verb comprehension <br> From the following please extract the verbs <br> now explain each in context <br> Next, use picture descriptions for each word in the verb list <br> Create combinations using the verb list <hr> ")
|
939 |
+
gr.HTML("Tree and Branches approach to learning = familiarity with keywords/headings/summaries before reading the whole text <hr> Productivity/Work revolves around repitition which can be found looking for plurals and grouping terms eg. Headings and Hyper/Hyponyms Analysis")
|
940 |
+
with gr.Tab("AR"):
|
941 |
+
gr.Textbox("Alpha Test version = Real time Lablling of All things in view using SAM and Clip Interrogator and OpenCV on pydroid --> Adjusted Demo")
|
942 |
+
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 ")
|
943 |
+
gr.HTML("<a href='https://huggingface.co/spaces/curt-park/segment-anything-with-clip'> -- SAM with Clip -- </a>")
|
944 |
+
gr.Interface(fn=arrealtimetestidea, inputs='image', outputs="text", description="Vision Assistant - see and execute")
|
945 |
+
gr.Textbox("Placeholder for webcam stream")
|
946 |
+
#gr.Interface(fn=arrealtimetestidea, inputs='webcam', outputs="text", description="Vision Assistant aka Free Observation llm judgement (GPT Vision API goes here when released). FPS is the difference between realtime app and static image")
|
947 |
+
with gr.Tab("Random Ideas"):
|
948 |
+
gr.HTML("""<p>Spaces Test - Still Undercontruction --> Next Milestone is Turning this interface handsfree | Knowledge is a Language but productive knowledge is find replace as well | LingQ is good option for per word state management</p> <p> Arrows app json creator for easy knowledge graphing and spacy POS graph? --> Questions? -->
|
949 |
+
<p> ChatGPT Turns Learning into a read only what you dont know ask only what you dont know feedback loop --> All you have to do is keep track of what prompts you have asked in the past</p> """)
|
950 |
+
gr.HTML("<p>Target 0: Mnemonics as title of images --> Comprehensible input <br> Target 1: Dual audio at word Level while using repitition to train random recall --> Word level Time <br> Target 2: Video --> Split by sentence --> each word repeated (60) + each phrase (10) + each sentence (10) --> TTS file for practice --> State Management/Known word Tracker <br>-----------------------<br> The trick is minimum one minute of focus on a new word --> Listening is hard because there are new word within seconds and you need repeated focus on each to learn </p> <p>Audio = best long form attention mechanism AS it is ANTICIPATION (Awareness of something before it happens like knowing song Lyrics) FOCUSED - Attention (Focused Repitition) + Exposure (Random Repitition) </p> <p>Listening is hard due to different word order and word combinations (collocations more important than single words)</p> <hr>")
|
951 |
+
gr.HTML("Predictable to identify the parts of picture being described --> The description moves in one direction from one side of the image to the other side is easiest <hr>")
|
952 |
+
gr.HTML("Image = instant comprehension like Stable Diffusion --> Audiovisual experience is the most optimal reading experience <br> Manga with summary descriptions for the chapters = Most aligned visual to audio experience")
|
953 |
+
with gr.Tab("LLM Prompts and games"):
|
954 |
+
gr.HTML(LLPromptIdeas)
|
955 |
+
|
956 |
+
lliface.queue().launch() #(inbrowser="true")
|
requirements.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
googletrans==3.1.0a0
|
2 |
+
spacy
|
3 |
+
gradio
|
4 |
+
nltk
|
5 |
+
wikipedia
|
6 |
+
ffmpeg-python
|
7 |
+
gTTS
|
8 |
+
python-docx
|
9 |
+
pykakasi
|
10 |
+
hangul_romanize
|
11 |
+
pinyin
|
12 |
+
langdetect
|