Spaces:
Running
Running
feat: Allow users to paste in their own openai api key
Browse files
src/pronunciation_trainer/app.py
CHANGED
@@ -5,6 +5,7 @@ This script provides a simple web interface for the pronunciation trainer using
|
|
5 |
|
6 |
from pathlib import Path
|
7 |
|
|
|
8 |
import gradio as gr
|
9 |
from phonemizer import phonemize
|
10 |
|
@@ -88,6 +89,15 @@ with gr.Blocks() as demo:
|
|
88 |
learner_l2 = gr.Textbox(
|
89 |
label="Language the learner aims to acquire (L2)", placeholder="English"
|
90 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
advanced_evaluate_btn = gr.Button("Evaluate", variant="primary")
|
92 |
gr.Markdown("## Advanced Evaluation")
|
93 |
|
@@ -125,6 +135,7 @@ with gr.Blocks() as demo:
|
|
125 |
learner_l2,
|
126 |
learner_phoneme_transcription,
|
127 |
teacher_phoneme_transcription,
|
|
|
128 |
],
|
129 |
outputs=llm_evaluation,
|
130 |
)
|
|
|
5 |
|
6 |
from pathlib import Path
|
7 |
|
8 |
+
import os
|
9 |
import gradio as gr
|
10 |
from phonemizer import phonemize
|
11 |
|
|
|
89 |
learner_l2 = gr.Textbox(
|
90 |
label="Language the learner aims to acquire (L2)", placeholder="English"
|
91 |
)
|
92 |
+
openai_api_key = gr.Textbox(
|
93 |
+
placeholder="Paste your OpenAI API key (sk-...)",
|
94 |
+
show_label=False,
|
95 |
+
value=os.getenv("OPENAI_API_KEY"),
|
96 |
+
label="openai_api_key",
|
97 |
+
lines=1,
|
98 |
+
type="password",
|
99 |
+
)
|
100 |
+
|
101 |
advanced_evaluate_btn = gr.Button("Evaluate", variant="primary")
|
102 |
gr.Markdown("## Advanced Evaluation")
|
103 |
|
|
|
135 |
learner_l2,
|
136 |
learner_phoneme_transcription,
|
137 |
teacher_phoneme_transcription,
|
138 |
+
openai_api_key,
|
139 |
],
|
140 |
outputs=llm_evaluation,
|
141 |
)
|
src/pronunciation_trainer/evaluation.py
CHANGED
@@ -73,9 +73,10 @@ def advanced_evaluation(
|
|
73 |
learner_l2,
|
74 |
learner_phoneme_transcription,
|
75 |
teacher_phoneme_transcription,
|
|
|
76 |
) -> str:
|
77 |
"""Provide LLM-based feedback"""
|
78 |
-
return create_llm_chain().invoke(
|
79 |
{
|
80 |
"learner_l1": learner_l1,
|
81 |
"learner_l2": learner_l2,
|
|
|
73 |
learner_l2,
|
74 |
learner_phoneme_transcription,
|
75 |
teacher_phoneme_transcription,
|
76 |
+
openai_api_key,
|
77 |
) -> str:
|
78 |
"""Provide LLM-based feedback"""
|
79 |
+
return create_llm_chain(openai_api_key=openai_api_key).invoke(
|
80 |
{
|
81 |
"learner_l1": learner_l1,
|
82 |
"learner_l2": learner_l2,
|