mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-22 05:09:05 +00:00
return both en and fr in transcriptio
This commit is contained in:
@@ -58,7 +58,10 @@ class AudioTranscriptModalProcessor(AudioTranscriptProcessor):
|
||||
# Update code here once this is possible.
|
||||
# i.e) extract from context/session objects
|
||||
source_language = "en"
|
||||
target_language = "en"
|
||||
|
||||
# TODO: target lang is set to "fr" for demo purposes
|
||||
# Revert back once language selection is implemented
|
||||
target_language = "fr"
|
||||
languages = TranslationLanguages()
|
||||
|
||||
# Only way to set the target should be the UI element like dropdown.
|
||||
@@ -74,7 +77,7 @@ class AudioTranscriptModalProcessor(AudioTranscriptProcessor):
|
||||
files=files,
|
||||
timeout=self.timeout,
|
||||
headers=self.headers,
|
||||
json=json_payload,
|
||||
data=json_payload,
|
||||
)
|
||||
|
||||
self.logger.debug(
|
||||
@@ -84,12 +87,14 @@ class AudioTranscriptModalProcessor(AudioTranscriptProcessor):
|
||||
result = response.json()
|
||||
|
||||
# Sanity check for translation status in the result
|
||||
translation = ""
|
||||
if target_language in result["text"]:
|
||||
text = result["text"][target_language]
|
||||
else:
|
||||
text = result["text"][source_language]
|
||||
translation = result["text"][target_language]
|
||||
text = result["text"][source_language]
|
||||
|
||||
transcript = Transcript(
|
||||
text=text,
|
||||
translation=translation,
|
||||
words=[
|
||||
Word(
|
||||
text=word["text"],
|
||||
|
||||
@@ -34,12 +34,12 @@ class TranscriptLinerProcessor(Processor):
|
||||
if "." not in word.text:
|
||||
continue
|
||||
|
||||
partial.translation = self.transcript.translation
|
||||
# emit line
|
||||
await self.emit(partial)
|
||||
|
||||
# create new transcript
|
||||
partial = Transcript(words=[])
|
||||
|
||||
self.transcript = partial
|
||||
|
||||
async def _flush(self):
|
||||
|
||||
@@ -47,6 +47,7 @@ class Word(BaseModel):
|
||||
|
||||
class Transcript(BaseModel):
|
||||
text: str = ""
|
||||
translation: str = ""
|
||||
words: list[Word] = None
|
||||
|
||||
@property
|
||||
@@ -84,7 +85,7 @@ class Transcript(BaseModel):
|
||||
words = [
|
||||
Word(text=word.text, start=word.start, end=word.end) for word in self.words
|
||||
]
|
||||
return Transcript(text=self.text, words=words)
|
||||
return Transcript(text=self.text, translation=self.translation, words=words)
|
||||
|
||||
|
||||
class TitleSummary(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user