start to integrate whisper.
This commit is contained in:
@ -76,5 +76,6 @@ export class CachedTranslator extends Translator {
|
||||
const tr2 = await super.translate(text, target);
|
||||
const key2 = `${this.source}::${targetKey}::${text}`
|
||||
await cache.set(key2, tr2);
|
||||
return tr2;
|
||||
}
|
||||
}
|
@ -32,6 +32,10 @@ export default function Home() {
|
||||
);
|
||||
}
|
||||
|
||||
function onGoBack() {
|
||||
setConversation(undefined);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Stack.Screen
|
||||
@ -46,7 +50,7 @@ export default function Home() {
|
||||
/>
|
||||
<Text>Home Screen</Text>
|
||||
{conversation ? (
|
||||
<ConversationThread conversation={conversation} />
|
||||
<ConversationThread conversation={conversation} onGoBack={onGoBack} />
|
||||
) : (
|
||||
<LanguageSelection onLangSelected={onLangSelected} />
|
||||
)}
|
||||
|
@ -14,9 +14,10 @@ export class Message {
|
||||
|
||||
constructor (public conversation : Conversation, public speaker : Speaker, public text? : string) {}
|
||||
|
||||
public async translate(translator : Translator, language? : string) {
|
||||
public async translate() {
|
||||
const translator = this.conversation.translator
|
||||
if (!this.text) throw new Error("No text")
|
||||
this.translation = await translator.translate(this.text, language);
|
||||
this.translation = await translator.translate(this.text, this.otherLanguage);
|
||||
}
|
||||
|
||||
get otherSpeaker() {
|
||||
@ -34,7 +35,7 @@ export class Conversation extends Array<Message> {
|
||||
public onTranslationDone? : (conversation : Conversation) => any;
|
||||
|
||||
constructor (
|
||||
private translator : Translator,
|
||||
public translator : Translator,
|
||||
public host : Speaker,
|
||||
public guest : Speaker,
|
||||
) {
|
||||
@ -48,7 +49,7 @@ export class Conversation extends Array<Message> {
|
||||
public async translateMessage(i : number) {
|
||||
if (!this[i]) throw new Error(`${i} is not a valid message number`);
|
||||
console.log(`Translating sentence to %s: %s`, this[i].otherLanguage, this[i].text)
|
||||
await this[i].translate(this.translator, this[i].otherLanguage);
|
||||
await this[i].translate();
|
||||
}
|
||||
|
||||
get lastMessage() {
|
||||
|
Reference in New Issue
Block a user