Skip to content

Commit

Permalink
Add screenshots, improve prompt, increase timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
RickCarlino committed May 28, 2023
1 parent 1d8c68e commit 23e2f0c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
<p align="center">
<img src="./logo.png" alt="The KoalaSRS Logo (for now)"/>
</p>
<p align="center">
<img src="./screenshot.jpg" alt="The KoalaSRS Logo (for now)"/>
</p>

Hey there! Welcome to KoalaSRS, a fun and friendly Korean-only [spaced repetition system](https://en.wikipedia.org/wiki/Spaced_repetition) that's all about listening and speaking skills. We teach vocabulary using fully-formed sentences, not just boring word/definition pairs. KoalaSRS captures your voice input using speech-to-text and uses the super-smart GPT-3 for human-like test assessments and corrections. That means that the app is clever enough to mark your answers as "close enough" and can even give you optional feedback about _why_ you were wrong (Called "coaching"- UI is not built yet). It can explain sentences that don't make sense or have unknown vocabulary. 🧠

Hey there! Welcome to KoalaSRS, a fun and friendly Korean-only [spaced repetition system](https://en.wikipedia.org/wiki/Spaced_repetition) that's all about listening and speaking skills. We teach vocabulary using fully-formed sentences, not just boring word/definition pairs. KoalaSRS captures your voice input using speech-to-text and uses the super-smart GPT-3 for human-like test assessments and corrections. That means that the app is clever enough to mark your answers as "close enough" and can even give you optional feedback about _why_ you were wrong ("coaching"). It can explain sentences that don't make sense or have unknown vocabulary. 🧠

## UNDER CONSTRUCTION ⚠️

Expand Down Expand Up @@ -40,8 +44,6 @@ The app has three types of quizzes:
- **Listening quiz:** You listen to a Korean phrase and then translate it to English. This quiz comes after the dictation phase. 🎶
- **Speaking quiz:** You get an English text and are asked to say it in Korean. The program transcribes your phrase via speech-to-text, and GPT-3 grades your answer. 📣

The app also has a **coaching** feature where you can ask GPT for guidance on unknown words and grammar after a failed quiz. While coaching is mostly effective, remember that language models like GPT can ["hallucinate"](<https://en.wikipedia.org/wiki/Hallucination_(artificial_intelligence)>), so double-check all lessons learned via coaching. 🔍

Please note that this app is not ready for non-technical users just yet. If you want to try the app, you'll need to clone this repo and build it on your local machine (Linux only). There's no public demo available, but we'd love your feedback! 😊

The program also comes with helper functions for formatting prompts, grading responses, and inspecting results.
Expand Down
Binary file added screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 24 additions & 17 deletions server/routers/_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { draw } from "radash";
import { z } from "zod";
import { procedure, router } from "../trpc";

const PROMPT_CONFIG = { best_of: 1, temperature: 0.2 };

const apiKey = process.env.OPENAI_API_KEY;

if (!apiKey) {
Expand Down Expand Up @@ -46,14 +48,16 @@ const cleanYesNo = (answer?: string) => {

const translationPrompt = (ko: string, response: string) => {
return `
A Korean language student was asked to translate the following phrase to english: ${ko}.
The student provided this translation: ${response}
Was the student correct?
A Korean language learning app user was asked to translate
the following phrase to english: ${ko}.
The user provided this translation: ${response}
Was the user correct?
Slight variations in spacing and punctuation are acceptable.
The meanings of the two sentences must express the exact same idea.
Punctuation and word choice do not need to be exact.
Reply "YES" if it is a correct translation.
Reply "NO" if it is incorrect, then provide a reason why it is wrong
Reply "NO" if it is incorrect, then provide a display
reason for why it is wrong
`;
};

Expand Down Expand Up @@ -108,6 +112,7 @@ async function gradeResp(answer: string = "", phrase: Phrase) {
await markCorrect(phrase);
return true;
case "NO":
console.log(answer);
await markIncorrect(phrase);
return false;
default:
Expand All @@ -116,42 +121,43 @@ async function gradeResp(answer: string = "", phrase: Phrase) {
}

async function dictationTest(transcript: string, phrase: Phrase) {
const [answer] = await ask(
`
A Korean language student was asked to read the following phrase aloud: ${phrase.ko}.
The student read: ${transcript}
Was the student correct?
const [answer] = await ask(`
A Korean language learning app user was asked to read the
following phrase aloud: ${phrase.ko} (${phrase.en}).
The user read: ${transcript}
Was the user correct?
Slight variations in spacing and punctuation are acceptable.
The meanings of the two sentences must express the exact same idea.
Punctuation and word choice do not need to be exact.
Reply "YES" if it is correct.
Reply "NO" if it is incorrect, then provide a reason why it is wrong
Reply "NO" if it is incorrect, then provide a display reason
why it is wrong
(YES/NO)
`,
{ best_of: 1, temperature: 0.2 }
PROMPT_CONFIG
);
return gradeResp(answer, phrase);
}

async function listeningTest(transcript: string, phrase: Phrase) {
const p = translationPrompt(phrase.ko, transcript);
const [answer] = await ask(p);
const [answer] = await ask(p, PROMPT_CONFIG);
return gradeResp(answer, phrase);
}

async function speakingTest(transcript: string, phrase: Phrase) {
const [answer] = await ask(
`An English-speaking Korean language student was asked
to translate the following phrase to Korean: ${phrase.en}.
The student said: ${transcript}
Was the student correct?
`An English-speaking Korean language learning app user was asked
to translate the following phrase to Korean: ${phrase.en} (${phrase.ko}).
The user said: ${transcript}
Was the user correct?
Slight variations in spacing and punctuation are acceptable.
The meanings of the two sentences must express the exact same idea.
Punctuation and word choice do not need to be exact.
Reply "YES" if it is correct.
Reply "NO" if it is incorrect, then provide a reason why it is wrong
`,
{ best_of: 1, temperature: 0.2 }
PROMPT_CONFIG
);
return gradeResp(answer, phrase);
}
Expand Down Expand Up @@ -286,6 +292,7 @@ export const appRouter = router({
where: { id: input.id },
});
if (transcript.kind === "error") {
console.log(`Transcription error`);
return { result: "error" } as const;
}
const result = phrase && (await quiz(transcript.text, phrase));
Expand Down
2 changes: 1 addition & 1 deletion utils/transcribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function transcribeB64(
);

const timeoutPromise = new Promise<TranscriptionResult>((resolve, _) =>
setTimeout(() => resolve({ kind: "error" }), 3500)
setTimeout(() => resolve({ kind: "error" }), 4321)
);

return Promise.race([transcribePromise, timeoutPromise]);
Expand Down

0 comments on commit 23e2f0c

Please sign in to comment.