Spaces:
Runtime error
Runtime error
File size: 52,388 Bytes
6c4f541 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
from googletrans import Translator
import spacy
import gradio as gr
import nltk
from nltk.corpus import wordnet
import wikipedia
import re
import time
import random
import os
import zipfile
import ffmpeg
from gtts import gTTS
#from io import BytesIO
from collections import Counter
from PIL import Image, ImageDraw, ImageFont
import numpy as np
from docx import Document
import textwrap
import pandas as pd
#Uncomment these for Huggingface
nltk.download('maxent_ne_chunker') #Chunker
nltk.download('stopwords') #Stop Words List (Mainly Roman Languages)
nltk.download('words') #200 000+ Alphabetical order list
nltk.download('punkt') #Tokenizer
nltk.download('verbnet') #For Description of Verbs
nltk.download('omw')
nltk.download('omw-1.4') #Multilingual Wordnet
nltk.download('wordnet') #For Definitions, Antonyms and Synonyms
nltk.download('shakespeare')
nltk.download('dolch') #Sight words
nltk.download('names') #People Names NER
nltk.download('gazetteers') #Location NER
nltk.download('opinion_lexicon') #Sentiment words
nltk.download('averaged_perceptron_tagger') #Parts of Speech Tagging
spacy.cli.download("en_core_web_sm")
spacy.cli.download('ko_core_news_sm')
spacy.cli.download('ja_core_news_sm')
spacy.cli.download('zh_core_web_sm')
nlp = spacy.load('en_core_web_sm')
translator = Translator()
def Sentencechunker(sentence):
Sentchunks = sentence.split(" ")
chunks = []
for i in range(len(Sentchunks)):
chunks.append(" ".join(Sentchunks[:i+1]))
return " | ".join(chunks)
def ReverseSentenceChunker(sentence):
reversed_sentence = " ".join(reversed(sentence.split()))
chunks = Sentencechunker(reversed_sentence)
return chunks
def three_words_chunk(sentence):
words = sentence.split()
chunks = [words[i:i+3] for i in range(len(words)-2)]
chunks = [" ".join(chunk) for chunk in chunks]
return " | ".join(chunks)
def keep_nouns_verbs(sentence):
doc = nlp(sentence)
nouns_verbs = []
for token in doc:
if token.pos_ in ['NOUN','VERB','PUNCT']:
nouns_verbs.append(token.text)
return " ".join(nouns_verbs)
def unique_word_count(text="", state=None):
if state is None:
state = {}
words = text.split()
word_counts = state
for word in words:
if word in word_counts:
word_counts[word] += 1
else:
word_counts[word] = 1
sorted_word_counts = sorted(word_counts.items(), key=lambda x: x[1], reverse=True)
return sorted_word_counts,
def Wordchunker(word):
chunks = []
for i in range(len(word)):
chunks.append(word[:i+1])
return chunks
def BatchWordChunk(sentence):
words = sentence.split(" ")
FinalOutput = ""
Currentchunks = ""
ChunksasString = ""
for word in words:
ChunksasString = ""
Currentchunks = Wordchunker(word)
for chunk in Currentchunks:
ChunksasString += chunk + " "
FinalOutput += "\n" + ChunksasString
return FinalOutput
# Translate from English to French
langdest = gr.Dropdown(choices=["af", "de", "es", "ko", "ja", "zh-cn"], label="Choose Language", value="de")
ChunkModeDrop = gr.Dropdown(choices=["Chunks", "Reverse", "Three Word Chunks", "Spelling Chunks"], label="Choose Chunk Type", value="Chunks")
def FrontRevSentChunk (Chunkmode, Translate, Text, langdest):
FinalOutput = ""
TransFinalOutput = ""
if Chunkmode=="Chunks":
FinalOutput += Sentencechunker(Text)
if Chunkmode=="Reverse":
FinalOutput += ReverseSentenceChunker(Text)
if Chunkmode=="Three Word Chunks":
FinalOutput += three_words_chunk(Text)
if Chunkmode=="Spelling Chunks":
FinalOutput += BatchWordChunk(Text)
if Translate:
TransFinalOutput = FinalOutput
translated = translator.translate(TransFinalOutput, dest=langdest)
FinalOutput += "\n" + translated.text
return FinalOutput
# Define a function to filter out non-verb, noun, or adjective words
def filter_words(words):
# Use NLTK to tag each word with its part of speech
tagged_words = nltk.pos_tag(words)
# Define a set of parts of speech to keep (verbs, nouns, adjectives)
keep_pos = {'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ', 'NN', 'NNS', 'NNP', 'NNPS', 'JJ', 'JJR', 'JJS'}
# Filter the list to only include words with the desired parts of speech
filtered_words = [word for word, pos in tagged_words if pos in keep_pos]
return filtered_words
def SepHypandSynExpansion(text):
# Tokenize the text
tokens = nltk.word_tokenize(text)
NoHits = ""
FinalOutput = ""
# Find synonyms and hypernyms of each word in the text
for token in tokens:
synonyms = []
hypernyms = []
for synset in wordnet.synsets(token):
synonyms += synset.lemma_names()
hypernyms += [hypernym.name() for hypernym in synset.hypernyms()]
if not synonyms and not hypernyms:
NoHits += f"{token} | "
else:
FinalOutput += "\n" f"{token}: hypernyms={hypernyms}, synonyms={synonyms} \n"
NoHits = set(NoHits.split(" | "))
NoHits = filter_words(NoHits)
NoHits = "Words to pay special attention to: \n" + str(NoHits)
return NoHits, FinalOutput
def WikiSearch(term):
termtoks = term.split(" ")
for item in termtoks:
# Search for the term on Wikipedia and get the first result
result = wikipedia.search(item, results=20)
return result
def create_dictionary(word_list, word_dict = {}):
word_list = set(word_list.split(" "))
for word in word_list:
key = word[:2]
if key not in word_dict:
word_dict[key] = [word]
else:
word_dict[key].append(word)
return word_dict
def merge_lines(roman_file, w4w_file, full_mean_file, macaronic_file):
files = [roman_file, w4w_file, full_mean_file, macaronic_file]
merged_lines = []
with open(roman_file.name, "r") as f1, open(w4w_file.name, "r") as f2, \
open(full_mean_file.name, "r") as f3, open(macaronic_file.name, "r") as f4:
for lines in zip(f1, f2, f3, f4):
merged_line = "\n".join(line.strip() for line in lines)
merged_lines.append(merged_line)
return "\n".join(merged_lines)
TTSLangOptions = gr.Dropdown(choices=["en", "de", "es", "ja", "ko", "zh-cn"], value="en", label="choose the language of the srt/text accent")
TTSLangOptions2 = gr.Dropdown(choices=["en", "de", "es", "ja", "ko", "zh-cn"], value="en", label="choose the language of the srt/text accent")
def TTSforListeningPractice(text, language = "en", Repeat10x = False):
if Repeat10x:
text = text * 10
speech = gTTS(text=text, lang=language, slow="False")
speech.save("CurrentTTSFile.mp3")
#file = BytesIO()
#speech.write_to_fp(file)
#file.seek(0)
return "CurrentTTSFile.mp3" #file
def AutoChorusInvestigator(sentences):
sentences = sentences.splitlines()
# Use Counter to count the number of occurrences of each sentence
sentence_counts = Counter(sentences)
# Identify duplicate sentences
duplicates = [s for s, count in sentence_counts.items() if count > 1]
FinalOutput = ""
if len(duplicates) == 0:
FinalOutput += "No duplicate sentences found in the file."
else:
FinalOutput += "The following sentences appear more than once in the file:"
for sentence in duplicates:
FinalOutput += "\n" + sentence
return FinalOutput
def AutoChorusPerWordScheduler(sentences):
words = set(sentences.split(" "))
wordsoneattime =[]
practicestring = ""
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"
for word in words:
wordsoneattime.append(word)
for i in range(0, 59):
practicestring += word + " "
practicestring += random.choice(wordsoneattime) + " "
FinalOutput += word + "\n "
practicestring += "\n"
FinalOutput += practicestring
return FinalOutput
def group_words(inlist):
inlisttoks = inlist.split(" ")
inlistset = set(inlisttoks)
word_groups = []
current_group = []
for word in inlisttoks:
current_group.append(word)
if len(current_group) == 10:
word_groups.append(current_group)
current_group = []
if current_group:
word_groups.append(current_group)
current_group_index = 0
current_group_time = 0
while True:
if current_group_time == 60:
current_group_index = (current_group_index + 1) % len(word_groups)
current_group_time = 0
else:
if current_group_time % 10 == 0:
random.shuffle(word_groups[current_group_index])
current_group_time += 10
yield " ".join(word_groups[current_group_index])
time.sleep(10)
def split_verbs_nouns(text):
nlp = spacy.load("en_core_web_sm")
doc = nlp(text)
verbs_nouns = []
other_words = []
pos_string = []
for token in doc:
if token.pos_ in ["VERB", "NOUN"]:
verbs_nouns.append(token.text)
elif token.text in [punct.text for punct in doc if punct.is_punct]:
verbs_nouns.append(token.text)
other_words.append(token.text)
else:
other_words.append(token.text)
pos_string.append(token.pos_)
verbs_nouns_text = " ".join(verbs_nouns)
other_words_text = " ".join(other_words)
pos_string_text = " ".join(pos_string)
return pos_string_text, verbs_nouns_text, other_words_text
SRTLangOptions = gr.Dropdown(choices=["en", "ja", "ko", "zh-cn"], value="en", label="choose the language of the srt")
def save_string_to_file(string_to_save, file_name, srtdocx):
with open(file_name, 'w', encoding='utf-8') as file:
file.write(string_to_save)
if srtdocx == "True":
with open(file_name.split('.')[0] + '.srt', 'w', encoding='utf-8') as file:
file.write(string_to_save)
srtdocument = Document()
srtdocument.add_paragraph(string_to_save)
srtdocument.save('SplitSRT.docx')
def split_srt_file(text, lang): #file_path):
# Open the SRT file and read its contents
#with open(file_path, 'r') as f:
# srt_contents = f.read()
if lang == "en": nlp = spacy.load('en_core_web_sm')
if lang == "ja": nlp = spacy.load('ja_core_news_sm')
if lang == "ko": nlp = spacy.load('ko_core_news_sm')
if lang == "zn-cn": nlp = spacy.load('zn_core_web_sm')
srt_contents = text
# Split the SRT file by timestamp
srt_sections = srt_contents.split('\n\n')
srt_sections_POSversion = []
subaswordlist = ""
# Loop through each section of the SRT file
for i in range(len(srt_sections)):
# Split the section into its timestamp and subtitle text
section_lines = srt_sections[i].split('\n')
timestamp = section_lines[1]
subtitle_text = ' | '.join(section_lines[2:])
sub_split_line = nlp(subtitle_text)
subtitle_textPOSversion = ""
subtitle_text = ""
# Replace spaces in the subtitle text with " | "
#subtitle_text = subtitle_text.replace(' ', ' | ')
for token in sub_split_line:
subtitle_text += token.text + " | "
subaswordlist += token.text + " "
subtitle_textPOSversion += token.pos_ + " | "
# Reconstruct the section with the updated subtitle text
srt_sections[i] = f"{section_lines[0]}\n{timestamp}\n{subtitle_text[3:]}"
srt_sections_POSversion.append(f"{section_lines[0]}\n{timestamp}\n{subtitle_textPOSversion[3:]}\n\n")
SplitSRT = '\n\n'.join(srt_sections)
SplitPOSsrt = ''.join(srt_sections_POSversion)
save_string_to_file(SplitSRT, "SplitSRT.txt", "True")
save_string_to_file(SplitPOSsrt, "SplitPOSsrt.txt", "False")
subaswordlist = set(subaswordlist.split(" "))
subaswordlistOutput = ""
for word in subaswordlist:
subaswordlistOutput += "\n | " + word
subaswordlistOutput = str(len(subaswordlist)) + "\n" + subaswordlistOutput
# Join the SRT sections back together into a single string
return subaswordlistOutput, ["SplitSRT.docx", "SplitSRT.txt", "SplitSRT.srt", "SplitPOSsrt.txt"], SplitSRT, SplitPOSsrt
def find_string_positions(s, string):
positions = []
start = 0
while True:
position = s.find(string, start)
if position == -1:
break
positions.append(position)
start = position + len(string)
return positions
def splittext(string):
string_no_formaterror = string.replace(" -- > ", " --> ")
split_positions = find_string_positions(string_no_formaterror, " --> ")
split_strings = []
prepos = 0
for pos in split_positions:
pos -= 12
split_strings.append((string[prepos:pos])) #, string[pos:]))
prepos = pos
FinalOutput = ""
stoutput = ""
linenumber = 1
#print(linenumber)
for item in split_strings[1:]:
stoutput = item[0:29] + "\n" + item[30:]
stspaces = find_string_positions(stoutput, " ")
FinalOutput += str(linenumber) + "\n" + stoutput[:stspaces[-2]] + "\n"
FinalOutput += "\n"
linenumber += 1
return FinalOutput[2:]
def VideotoSegment(video_file, subtitle_file):
# Read the subtitle file and extract the timings for each subtitle
timings = []
for line in subtitle_file:
if '-->' in line:
start, end = line.split('-->')
start_time = start.strip().replace(',', '.')
end_time = end.strip().replace(',', '.')
timings.append((start_time, end_time))
# Cut the video into segments based on the subtitle timings
video_segments = []
for i, (start_time, end_time) in enumerate(timings):
output_file = f'segment_{i}.mp4'
ffmpeg.input(video_file, ss=start_time, to=end_time).output(output_file, codec='copy').run()
video_segments.append(output_file)
# Convert each segment to an MP3 audio file using FFmpeg
audio_segments = []
for i in range(len(timings)):
output_file = f'segment_{i}.mp3'
ffmpeg.input(video_segments[i]).output(output_file, codec='libmp3lame', qscale='4').run()
audio_segments.append(output_file)
# Create a ZIP archive containing all of the segmented files
zip_file = zipfile.ZipFile('segmented_files.zip', 'w')
for segment in video_segments + audio_segments:
zip_file.write(segment)
os.remove(segment)
zip_file.close()
# Return the ZIP archive for download
return 'segmented_files.zip'
def text_to_dropdown(text, id=None): #TextCompFormat
lines = text.strip().split("\n")
html = "<select"
if id:
html += f' id="{id}"'
html += "> \n"
for line in lines:
html += f" <option>{line}</option>\n"
html += "</select> \n"
return html
def text_to_links(text): #TextCompFormat
lines = text.strip().split("\n")
html = ""
for line in lines:
if line.startswith("http"):
html += f"<a href='{line}'> -- -- </a> | \n"
else:
html += line + "Not a link <br> \n"
return html
HTMLCompMode = gr.Dropdown(choices=["Dropdown", "Links"], value="Links")
def TextCompFormat(text, HTMLCompMode):
FinalOutput = ""
if HTMLCompMode == "Dropdown":
FinalOutput = text_to_dropdown(text)
if HTMLCompMode == "Links":
FinalOutput = text_to_links(text)
return FinalOutput
def create_collapsiblebutton(button_id, button_caption, div_content):
button_html = f'<button id="{button_id}" class="accordionbtn">{button_caption}</button>'
div_html = f'<div id="{button_id}Div" class="panel">\n{div_content}\n </div>'
return button_html + "\n " + div_html
#---------------
def removeTonalMarks(string):
tonalMarks = "āēīōūǖáéíóúǘǎěǐǒǔǚàèìòùǜɔɛ"
nonTonalMarks = "aeiouuaeiouuaeiouuaeiouoe"
noTonalMarksStr = ""
for char in string:
index = tonalMarks.find(char)
if index != -1:
noTonalMarksStr += nonTonalMarks[index]
else:
noTonalMarksStr += char
return noTonalMarksStr
def add_text_to_image(input_image, text, output_image_path="output.png", border_size=2):
text = removeTonalMarks(text)
imagearr = np.asarray(input_image) #Image.open(input_image_path)
width, height = imagearr.shape[:2] #width, height = image.size
img = Image.fromarray(imagearr)
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("ShortBaby.ttf", 36) #ShortBaby-Mg2w.ttf
text_width, text_height = draw.textbbox((0, 0), text, font=font)[2:] #draw.textsize(text, font)
# calculate the x, y coordinates of the text box
x = (width - text_width) / 2
y = (height - text_height) / 2
# put the text on the image with a border
for dx, dy in [(0, 0), (border_size, border_size), (-border_size, -border_size), (border_size, -border_size), (-border_size, border_size)]:
draw.text((x + dx, y + dy), text, font=font, fill=(255, 255, 255))
draw.text((x, y), text, font=font, fill=(0, 0, 0))
img.save(output_image_path, "PNG")
return "output.png"
def UnknownTrackTexttoApp(text): #Copy of def OptimisedTtAppForUNWFWO(text):
#Buttons and labels autocreation
#Change this to spacy version so that data is from one library
#Javascript videos on youtube - KodeBase - Change button color Onclick; bro code - button in 5 minutes
#GPT3 helped guide the highlighting if statements
FinalOutput = ""
#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"}
HTMLMainbody = ""
doc = nlp(text)
iIDNumber = 0
iVerbCount = 0
iNounCount = 0
iWords = 0
allverbs = ""
allverbslist = ""
allverbids = ""
allverbidslist = ""
for token in doc:
if (token.pos_ == "VERB") or (token.pos_ == "AUX"):
HTMLMainbody = HTMLMainbody + "<button id='btn" + str(iVerbCount) + "' onclick=HighlightWord('btn" + str(iVerbCount) + "')> " + token.text + "</button> "
allverbids = allverbids + str(iVerbCount) + " "
iVerbCount += 1
iWords += 1
allverbs = allverbs + token.text + " "
elif token.pos_ == "NOUN":
HTMLMainbody = HTMLMainbody + "<label class='Nouns' id='lbl" + token.text + "'>" + token.text + " </label>"
iNounCount += 1
iWords += 1
elif token.pos_ == "PUNCT":
HTMLMainbody = HTMLMainbody + token.text
else:
HTMLMainbody = HTMLMainbody + token.text + " "
iWords += 1
iIDNumber += 1
allverbslist = allverbs.split()
allverbidslist = allverbids.split()
FinalHTML = ""
FinalCSS = ""
FinalJS = ""
FinalCSS = FinalCSS + ''' <style>
body {
background-color: darksalmon;
}
.Nouns {
color: red;
}
.clunknown{
background-color: gainsboro;
}
.clknownl1{
background-color: yellow;
}
.clknownl2{
background-color: gold;
}
.clknownl3{
background-color: orange;
}
.PD1 {
text-align: center;
font-size: larger;
font-family: cursive;
}
.PD2 {
font-family: monospace;
}
</style>
'''
#style='background-color:Gainsboro; There is no general style attribute for buttons but you can make a class and put the style conditions
iSents = 0
for sent in doc.sents:
iSents += 1
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>"
FinalHTML = FinalHTML + "\n<div><hr><progress id='myVerbProgress' value='0' max='" + str(iVerbCount) + "'></progress></div>"
FinalJS = FinalJS + '''\n
<script>
function HighlightWord(Button){
if (document.getElementById(Button).style.backgroundColor === 'orange') {
document.getElementById(Button).style.backgroundColor=''
}
else if (document.getElementById(Button).style.backgroundColor === 'gold') {
document.getElementById(Button).style.backgroundColor='orange'
}
else if (document.getElementById(Button).style.backgroundColor === 'yellow') {
document.getElementById(Button).style.backgroundColor='gold'
}
else {document.getElementById(Button).style.backgroundColor='yellow'
}
OnlyUnknownVerbs()
}
'''
FinalHTML = FinalHTML + "\n<div><hr>\n" + HTMLMainbody + "\n"
#FinalHTML = FinalHTML + '''</div><hr>
#<button onclick=OnlyUnknownSentences() id="btnOnlyUnknownSentences">Only Unknown Sentences Put this function in a timer to keep up to date without input</button>
#'''
FinalJS = FinalJS + '''
function OnlyUnknownVerbs(){
AllButtons = ''' + str(allverbidslist) + '''
AllButtonsText = ''' + str(allverbslist) + '''
UnknownOutput = ""
iUnknownCount = 0
AllButtons.forEach(function(item){
if (document.getElementById('btn'+item).style.backgroundColor === ''){
UnknownOutput += AllButtonsText[item] + " "
iUnknownCount += 1
}
document.getElementById('myVerbProgress').value = ''' + str(iVerbCount) + ''' - iUnknownCount
})
document.getElementById('PD2').textContent = 'Only Unknwon words list: ' + UnknownOutput
}
</script>
'''
FinalHTML = FinalHTML + '''<br><hr><br>
<div id='PD2'> Only Unknown List</div>
\n
'''
FinalOutput = FinalHTML + FinalCSS + FinalJS
HTMLDownloadTemp = f'UnknownVerbTrack.html'
with open(HTMLDownloadTemp, 'w') as f:
f.write(FinalOutput)
return FinalOutput, FinalOutput, HTMLDownloadTemp
#Kathryn Lingel - Pyambic Pentameter Example - PyCon US
#Basic Language Model Code
def build_model(source_text):
list_of_words = source_text.split()
model = {} #initialise model to empty dictionary
for i, word in enumerate(list_of_words[:-1]): #every word except last word
if not word in model: #If word not already in dictionary as a key we add it and initialise to empty array
model[word] = []
next_word = list_of_words[i+1]
model[word].append(next_word) #model = dictionary per word containing previously seen next words from ANY given text ==> even lyrics
translatestring = str(model)
translatestring = translatestring.replace("'", "")
return model, translatestring
def markov_generate(source_text, num_words = 20):
model = build_model(source_text)
seed = random.choice(list(model.keys())) #Randomly pick a word ==> Heading of the dictionary are keys aka the words
output = [seed] #output initialisation using random word
for i in range(num_words):
last_word = output[-1] #of the output list
next_word = random.choice(model[last_word]) # next word to the above word
output.append(next_word) #new last word in the output list
if next_word not in model:
break
return ' '.join(output) #New list into a string aka (hopefully) sentence
# print(markov_generate("I am the egg man they are the egg men I am the wallrus goo goo g' joob"))
def chunk_srt_text(srt_text, chunk_size):
# Split the SRT text into chunks of the specified size
ChunkList = textwrap.wrap(srt_text, chunk_size)
dfFinalOutput = pd.DataFrame(ChunkList, columns = [f"Chunks - { len(ChunkList) }"])
return dfFinalOutput, ""
#-------------------------------------------------------------------------------------------------------------------------------
#Clean Merge
def split_into_fours(text):
lines = text.split('\n')
chunks = [lines[i:i+4] for i in range(0, len(lines), 4)]
return chunks
def NumberLineSort(listlen):
numbers = list(range(0, listlen)) # create a list of numbers 1 to 12
grouped_numbers = []
for i in range(4):
group = [numbers[j] for j in range(i, len(numbers), 4)]
grouped_numbers.append(group)
return grouped_numbers
def SRTLineSort(text):
chunks = split_into_fours(text)
NumberofBlocks = len(chunks) / 4
printnumber = NumberLineSort(len(chunks))
SRTLinenumber = []
SRTTiming = []
SRTContent = []
FinalOutput = ""
for i in range(0, 3):
for item in printnumber[i]:
if i == 0: SRTLinenumber.append(chunks[item][0])
if i == 1: SRTTiming.append(chunks[item][0])
if i == 2: SRTContent.append(chunks[item])
for i in range(0, int(NumberofBlocks)):
FinalOutput += SRTLinenumber[i] + "\n"
FinalOutput += SRTTiming[i] + "\n"
for i2 in range(0, 4):
FinalOutput += SRTContent[i][i2] + "\n"
FinalOutput += "\n"
return FinalOutput
#--------------------------------------------------------------------------------------------------------------------------------
RandomiseTextType = gr.Dropdown(choices=["Words", "Words5x", "Sentences", "Paragraph", "Page"], value="Words")
def RandomiseTextbyType(Text, Choice):
FinalOutput = ""
TempWords = []
if Choice == "Words" :
TempWords = Text.split()
FinalOutput = reading_randomize_words(TempWords)
if Choice == "Words5x" :
TempWords = Text.split()
FinalOutput = reading_randomize_words5x(TempWords)
if Choice == "Sentences" : FinalOutput = reading_randomize_words_in_sentence(Text)
if Choice == "Paragraph" : FinalOutput = reading_randomize_words_in_paragraph(Text)
if Choice == "Page" : FinalOutput = "Still under Construction"
return FinalOutput
def reading_randomize_words5x(word):
wordScram = ""
for item in word:
for i in range(5):
item = ''.join(random.sample(item, len(item)))
wordScram += " " + item
#print(item)
wordScram += "\n"
return wordScram
def reading_randomize_words(word):
wordScram = ""
for item in word:
item = ''.join(random.sample(item, len(item)))
wordScram += item + " "
return wordScram
def reading_randomize_words_in_sentence(text):
FinalOutput = ""
sentences = text.split(".")
for sentence in sentences:
words = sentence.split()
random.shuffle(words)
FinalOutput += ' '.join(words) + ". "
return FinalOutput
def reading_randomize_words_in_paragraph(paragraph):
sentences = paragraph.split(".")
random.shuffle(sentences)
return '. '.join(sentences)
def changeexposuretext(text):
return f"<marquee> {text} </marquee>"
#-------------------------------------------------------------------------------------------------------------------------------
def arrealtimetestidea(img):
return "Unfinished. The aim is to do realtime translation google but based on knowledge domains instead of language - Look at HF Models and spaces"
#------------------------------------------------------------------------------------------------------------------------------
LLPromptIdeas = """
<p> Make jokes while following rules for a syllogism jokes game:
The game can be played with any number of people.
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.
The next person must then state a syllogism that has the same conclusion as the first syllogism, but with different major and minor premises.
The game continues in this way until someone cannot think of a new syllogism.
The person who makes the last valid syllogism wins the game. </p>
<hr>
<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 </>
Bings Explanation
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:
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.
The game has two players: one who gives the English word and one who finds the <<Chinese>> word and makes the mnemonic.
The player who gives the English word can choose any word they want, as long as it has a <<Chinese>> equivalent.
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.
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>
"""
# Define the Gradio interface inputs and outputs for video split
spvvideo_file_input = gr.File(label='Video File')
spvsubtitle_file_input = gr.File(label='Subtitle File')
spvdownload_output = gr.File(label='Download Segmented Files')
Markovlength = gr.Number(value=30, label='Length of generation')
groupinput_text = gr.Textbox(lines=2, label="Enter a list of words")
groupoutput_text = gr.Textbox(label="Grouped words")
Translationchuncksize = gr.Number(value=4998)
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("']", "")
randomExposuremessage = f" <marquee> { randomExposuremessagelistitem } </marquee> "
with gr.Blocks() as lliface: #theme=gr.themes.Glass(primary_hue='green', secondary_hue='red', neutral_hue='blue', )
PracticeExposure = gr.HTML(randomExposuremessage)
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")
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>")
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> | """)
with gr.Row():
with gr.Column(scale=1):
with gr.Tab("Rep - Gradio"):
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">
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>""")
with gr.Tab("Rep - Gradio"):
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()
with gr.Tab("Navigation"):
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>")
PracticeExposureInput = gr.Textbox(placeholer="Exposure practice = look up", label="Exposure at the top")
PracticeExposurebtn = gr.Button("Change Default")
PracticeExposurebtn.click(fn=changeexposuretext, inputs=PracticeExposureInput, outputs=PracticeExposure)
with gr.Tab("Vector Database = Memorisation"):
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")
with gr.Column(scale=3):
with gr.Tab("Beginner - Listen + Read"):
with gr.Row():
with gr.Column(scale=1):
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>")
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)")
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>")
gr.Interface(fn=AutoChorusInvestigator, inputs="text", outputs="text", description="Paste Full Lyrics to try find only chorus lines")
gr.Interface(fn=AutoChorusPerWordScheduler, inputs="text", outputs="text", description="Create order of repitition for tts practice")
with gr.Column(scale=1):
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> | """)
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")
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")
#with gr.Tab("Transcribe - RASMUS Whisper"):
#gr.Interface.load("spaces/RASMUS/Whisper-youtube-crosslingual-subtitles", title="Subtitles")
with gr.Tab("Advanced - LingQ Addon Ideas"):
gr.HTML("<a href='https://www.lingq.com/en/'>Find LingQ Here --> https://www.lingq.com/en/</a>")
with gr.Tab("Visual - Multiline Custom Video Subtitles"):
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")
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>""")
#gr.HTML("<p>If Space not loaded its because of offline devopment errors please message for edit</p> <hr>")
with gr.Tab("Merged Subtitles"):
gr.HTML(""" Core Idea = Ability to follow one video from start to finish is more important than number of words (except for verbs) <hr>
Step 1 - Get foreign transcript - WHISPER (Need to download video though - booo) / Youtube / Youtube transcript api / SRT websites <br>
Step 2 - Get Translation of foreign transcript <br>
Step 3 - Word for Word Translation Creation in both Directions (Paste Google Translation here) <br>
""")
gr.Interface(fn=split_srt_file, inputs=["text", SRTLangOptions] , outputs=["text", "file", "text", "text"], description="SRT Contents to W4W Split SRT for Google Translate")
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')
gr.HTML("Step 4 - Pronounciation (Roman) to Subtitle Format --> GTranslate returns unformatted string")
gr.Interface(fn=splittext, inputs="text", outputs="text", description="Text for w4w creation in G Translate")
gr.HTML("Step 5 - Merge into one file")
with gr.Row():
RomanFile = gr.File(label="Paste Roman")
W4WFile = gr.File(label="Paste Word 4 Word")
FullMeanFile = gr.File(label="Paste Full Meaning")
MacaronicFile = gr.File(label="Paste Macaronic Text")
SentGramFormula = gr.File(label="Paste Sentence Grammar Formula Text")
with gr.Row():
MergeButton = gr.Button(label='Merge the seperate files into one interpolated file (Line by line merge)')
with gr.Row():
MergeOutput = gr.TextArea(label="Output")
MergeButton.click(merge_lines, inputs=[RomanFile, W4WFile, FullMeanFile, MacaronicFile], outputs=[MergeOutput], )
with gr.Row():
gr.Text("Make sure there are 4 spaces after the last subtitle block (Otherwise its skipped)")
CleanedMergeButton = gr.Button(label='Create a Usable file for SRT')
with gr.Row():
CleanedMergeOutput = gr.TextArea(label="Output")
CleanedMergeButton.click(fn=SRTLineSort, inputs=[MergeOutput], outputs=[CleanedMergeOutput])
with gr.Tab("Split video to segments"):
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>")
gr.Interface(VideotoSegment, inputs=[spvvideo_file_input, spvsubtitle_file_input], outputs=spvdownload_output)
gr.Text("Text to Closed Class + Adjectives + Punctuation or Noun Verb + Punctuation ")
with gr.Tab("Audio - Only English thoughts as practice"):
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")
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")
with gr.Tab("Transition is the end goal"):
with gr.Row():
with gr.Column():
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)
gr.Interface(fn=RandomiseTextbyType, inputs=["text", RandomiseTextType], outputs="text", description="Randomise order within words, sentences, paragrahs")
with gr.Column():
#with gr.Tab("Collocations (Markov)"):
gr.HTML("Transition is the true nature of logic i.e. like some form of non-semantic embedding that is semantic?")
gr.Interface(fn=build_model, inputs="text", outputs=["text", "text"], description="Create Collocation Dictionary --> Google Kathryn Lingel - Pyambic Pentameter Example - PyCon US for more")
gr.Interface(fn=markov_generate, inputs=["text", Markovlength], outputs="text", description="Generate Text based on the collocations in the text")
with gr.Column():
#with gr.Tab("Spelling + Chunks"):
gr.Textbox("Merged Spelling Practice Placeholder - Spell multiple words simultaneously for simultaneous access", lines=3)
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")
gr.Interface(fn=create_dictionary, inputs="text", outputs="text", title="Sort Text by first two letters")
gr.Interface(fn=keep_nouns_verbs, inputs=["text"], outputs="text", description="Noun and Verbs only (Plus punctuation)")
gr.Interface(fn=FrontRevSentChunk, inputs=[ChunkModeDrop, "checkbox", "text", langdest], outputs="text", description="Chunks creator")
with gr.Tab("Unknown Tracker"):
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>")
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")
gr.Textbox("Place holder for a translate to english interface so that highlighting can still work as only english supported for now")
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")
with gr.Tab("Unique word ID - use in Infranodus"):
gr.Interface(fn=unique_word_count, inputs="text", outputs="text", description="Wordcounter")
gr.Interface(fn=SepHypandSynExpansion, inputs="text", outputs=["text", "text"], description="Word suggestions - Analyse the unique words in infranodus")
gr.Interface(fn=WikiSearch, inputs="text", outputs="text", description="One word at a time Unique word suggestions (wiki articles)")
with gr.Tab("Automating related information linking"):
gr.HTML("Questions - Tacking and suggesting questions to ask = new education")
with gr.Tab("Thinking Practice"):
with gr.Tab("Sentence to Format"):
gr.Interface(fn=split_verbs_nouns , inputs="text", outputs=["text", "text", "text"], description="Comprehension reading and Sentence Format Creator")
with gr.Tab("Knowledge Ideas - Notetaking"):
gr.HTML("""<p>Good knowledge = ability to answer questions --> find Questions you cant answer and look for hidden answer within them </p>
<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>
<p>Big Picture = Expand the Heading and the subheadings and compare them to each other</p>
<p>Application of Knowledge = App Version of the text (eg. Jupyter Notebooks) is what you create and learn first</p>
""")
gr.Interface(fn=TextCompFormat, inputs=["textarea", HTMLCompMode], outputs="text", description="Convert Text to HTML Dropdown or Links which you paste in any html file")
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.")
with gr.Tab("Automated Reading Assitant"):
gr.Textbox('Parts of Speech based | Automating the Notetaking Tab either directly or using visual llm to use this interface efficiently')
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> ")
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")
with gr.Tab("AR"):
gr.Textbox("Alpha Test version = Real time Lablling of All things in view using SAM and Clip Interrogator and OpenCV on pydroid --> Adjusted Demo")
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 ")
gr.HTML("<a href='https://huggingface.co/spaces/curt-park/segment-anything-with-clip'> -- SAM with Clip -- </a>")
gr.Interface(fn=arrealtimetestidea, inputs='image', outputs="text", description="Vision Assistant - see and execute")
gr.Textbox("Placeholder for webcam stream")
#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")
with gr.Tab("Random Ideas"):
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? -->
<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> """)
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>")
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>")
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")
with gr.Tab("LLM Prompts and games"):
gr.HTML(LLPromptIdeas)
lliface.queue().launch() #(inbrowser="true") |