Skip to content

Commit

Permalink
Add Enum Language class to map language abbreviations to full languag…
Browse files Browse the repository at this point in the history
…e names to make it easier for users to choose an option from the dropdown. Closes #15
  • Loading branch information
Odrec committed Nov 26, 2024
1 parent 716c0cc commit 063202d
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dotenv import load_dotenv
from streamlit_quill import st_quill
import uuid

from enum import Enum

load_dotenv()

Expand All @@ -29,6 +29,24 @@
os.makedirs(base_temp_dir, exist_ok=True)


# Define the Language Enum
class Language(Enum):
GERMAN = ("German", "de")
ENGLISH = ("English", "en")
SPANISH = ("Spanish", "es")
FRENCH = ("French", "fr")
ITALIAN = ("Italian", "it")
JAPANESE = ("Japanese", "ja")
DUTCH = ("Dutch", "nl")
PORTUGUESE = ("Portuguese", "pt")
UKRAINIAN = ("Ukrainian", "uk")
CHINESE = ("Chinese", "zh")

def __init__(self, display_name, code):
self.display_name = display_name
self.code = code


def upload_file(file, lang, model, min_speakers, max_speakers):
files = {'file': file}
data = {
Expand Down Expand Up @@ -183,7 +201,6 @@ def callback_disable_controls():


with st.sidebar:

st.write("Upload a video or audio file or provide a YouTube link to get a transcription.")

form_key = "transcription_form"
Expand All @@ -199,7 +216,14 @@ def callback_disable_controls():
elif input_type == "YouTube Link":
st.session_state.youtube_link = st.text_input("Enter YouTube video link")

lang = st.selectbox("Select Language", ["de", "en", "es", "fr", "it", "ja", "nl", "pt", "uk", "zh"])
# Extract display names and display them in the selectbox
language_display_names = [language.display_name for language in Language]
selected_language_name = st.selectbox("Select Language", language_display_names)
# Retrieve the selected Language Enum member
selected_language = next(language for language in Language if language.display_name == selected_language_name)
# Get the abbreviation code for API calls
lang = selected_language.code

model = st.selectbox("Select Model", ["base", "large-v3"], index=0,
help="Base Model: for quick and low effort versions of your audio file "
"(balance between accuracy and speed of transcription). "
Expand Down

0 comments on commit 063202d

Please sign in to comment.