-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrazyTranscription.RichUI.py
89 lines (81 loc) · 3.79 KB
/
CrazyTranscription.RichUI.py
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
# -*- coding: utf-8 -*-
# Dependencies
from rich.console import Console
from rich.markup import escape
from CrazyTranscription import *
# Define the console
console = Console()
# Mainloop: Rich Interface
console.print("Welcome to CrazyTranscription!", style="bold blue", justify="center")
console.print(
"Version [blue bold]2.2.1.2 (Arctic Wolf)[/blue bold], made with [red bold]love[/red bold] by [link=https://github.com/ShiningYangYXN]Shining Yang[/link]"
)
console.print(
"Visit [link=https://github.com/ShiningYangYXN/CrazyTranscription]https://github.com/ShiningYangYXN/CrazyTranscription[/link] for project updates."
)
while True:
mode = ""
console.print("Please select a mode:", style="blue")
console.print(" [bold]\\[1][/bold] Transcription", style="green")
console.print(" [bold]\\[2][/bold] Reverse Transcription", style="yellow")
console.print(" [bold]\\[#][/bold] Exit", style="red")
mode = console.input("[blue bold]Mode: [/blue bold]")
if mode == "1":
mode = ""
modeNames = {
"1": "Greek",
"2": "Cyrillic",
"3": "Arabic",
"4": "Hebrew",
"5": "Sanskrit",
"6": "Tibetan",
}
while mode != "#":
console.print("Transcription mode. Please select a target:", style="blue")
console.print(" [bold]\\[1][/bold] Latin to Greek", style="blue")
console.print(" [bold]\\[2][/bold] Latin to Cyrillic", style="blue")
console.print(" [bold]\\[3][/bold] Latin to Arabic", style="blue")
console.print(" [bold]\\[4][/bold] Latin to Hebrew", style="blue")
console.print(" [bold]\\[5][/bold] Latin to Sanskrit", style="blue")
console.print(" [bold]\\[6][/bold] Latin to Tibetan", style="blue")
console.print(" [bold]\\[#][/bold] Exit", style="red")
mode = console.input("[blue bold]Mode: [/blue bold]")
if mode in ["1", "2", "3", "4", "5", "6"]:
selectedTranscriber = DefaultTranscribers[int(mode) - 1]
text = ""
console.print(
f"[blue bold]Latin to {modeNames[mode]}[/blue bold] Mode [green]selected[/green]. [red bold]Type '#' to exit.[/red bold]"
)
while text != "#":
text = console.input(
"[blue bold]Input your text to be transcribed:\n[/blue bold]"
)
console.rule(f"BEGIN {modeNames[mode].upper()} TRANSCRIPTION")
console.print(escape(selectedTranscriber.Transcribe(text)))
console.rule(f"END {modeNames[mode].upper()} TRANSCRIPTION")
console.print("OK,thanks. Goodbye.", style="blue bold")
elif mode == "#":
console.print("OK,thanks. Goodbye.", style="blue bold")
pass
else:
console.print("Invalid input. Please try again.", style="red bold")
elif mode == "2":
console.print(
"[blue bold]Reverse Transcription Mode.[/blue bold] [red bold]Type '#' to exit.[/red bold]"
)
text = ""
while text != "#":
text = console.input(
"[blue bold]Input your text to be transcribed:\n[/blue bold]"
)
console.rule("BEGIN REVERSE TRANSCRIPTION")
for t in DefaultTranscribers:
text = t.ReverseTranscribe(text)
console.print(escape(text))
console.rule("END REVERSE TRANSCRIPTION")
console.print("OK,thanks. Goodbye.", style="blue bold")
elif mode == "#":
console.print("OK,thanks. Goodbye.", style="blue bold")
break
else:
console.print("Invalid input. Please try again.", style="red bold")