@magmamath/students-features 1.3.23-rc.14 → 1.3.23-rc.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js +4 -3
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +3 -2
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +35 -27
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscription.js +4 -3
- package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +4 -3
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +1 -1
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +36 -28
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +2 -1
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +2 -1
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/voice/playing/components/VoiceTranscription.tsx +22 -10
- package/src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts +4 -3
- package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +35 -28
|
@@ -38,7 +38,7 @@ const VoiceTranscription = ({
|
|
|
38
38
|
const {
|
|
39
39
|
i18n
|
|
40
40
|
} = (0, _reactI18next.useTranslation)();
|
|
41
|
-
const [playerState, isLoadingTranscripts, isTranslationActive, translations, isTranslating] = (0, _effectorReact.useUnit)([model.$playerState, model.loader.loadAllTranscripts.pending, model.translation.$isActive, model.translation.$translations, model.translation.translate.pending]);
|
|
41
|
+
const [playerState, isLoadingTranscripts, loadedForAnswersKey, isTranslationActive, translations, isTranslating] = (0, _effectorReact.useUnit)([model.$playerState, model.loader.loadAllTranscripts.pending, model.loader.$loadedKey, model.translation.$isActive, model.translation.$translations, model.translation.translate.pending]);
|
|
42
42
|
const activeAttempt = (0, _helpers.getActiveAttempt)(attemptOffset, attemptsCount);
|
|
43
43
|
const isLargeVariant = variant === _types.VoiceTranscriptionVariant.LARGE;
|
|
44
44
|
const answersKey = (0, _react.useMemo)(() => answers.map(a => `${a._id}:${a.audioFileId ?? ''}`).join(','), [answers]);
|
|
@@ -49,11 +49,12 @@ const VoiceTranscription = ({
|
|
|
49
49
|
problemId,
|
|
50
50
|
activeAttempt
|
|
51
51
|
});
|
|
52
|
+
const isContentReady = loadedForAnswersKey === answersKey;
|
|
52
53
|
const hasActiveAudio = activeAttempt !== null && answers?.[activeAttempt - 1]?.audioFileId !== undefined;
|
|
53
|
-
const activeTranscript = activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null;
|
|
54
|
+
const activeTranscript = isContentReady && activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null;
|
|
54
55
|
const hasTranscriptText = !!activeTranscript && activeTranscript !== _constants.NO_AUDIO_BE_MESSAGE;
|
|
55
56
|
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript;
|
|
56
|
-
const transcriptLanguage = activeAttempt !== null ? model.loader.getTranscriptLanguage(activeAttempt) : undefined;
|
|
57
|
+
const transcriptLanguage = isContentReady && activeAttempt !== null ? model.loader.getTranscriptLanguage(activeAttempt) : undefined;
|
|
57
58
|
const isSourceSameAsTarget = !!transcriptLanguage && (0, _supportedLanguages.resolveGoogleLanguageCode)(transcriptLanguage) === (0, _supportedLanguages.resolveGoogleLanguageCode)(i18n.language);
|
|
58
59
|
const canTranslate = hasTranscriptText && !isSourceSameAsTarget;
|
|
59
60
|
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeUi","require","_effectorReact","_react","_interopRequireWildcard","_reactI18next","_reactNative","_reactNativeReanimated","_interopRequireDefault","_constants","_helpers","_types","_supportedLanguages","_i18n","_useVoiceTranscriptionEffects","_useVoiceTranscriptionAutoTranslate","_useVoiceTranscriptionAutoExpand","_VoiceTranscriptContent","_VoiceTranscriptionCollapsible","_VoiceTranscriptionHeaderActions","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","VoiceTranscriptionVariant","SMALL","useText","i18n","useTranslation","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","useUnit","$playerState","loader","loadAllTranscripts","pending","translation","$isActive","$translations","translate","activeAttempt","getActiveAttempt","isLargeVariant","LARGE","answersKey","useMemo","map","_id","audioFileId","join","useVoiceTranscriptionEffects","hasActiveAudio","undefined","activeTranscript","getTranscript","hasTranscriptText","NO_AUDIO_BE_MESSAGE","isActiveTranscriptLoading","transcriptLanguage","getTranscriptLanguage","isSourceSameAsTarget","resolveGoogleLanguageCode","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","useVoiceTranscriptionAutoTranslate","translationModel","useVoiceTranscriptionAutoExpand","targetLanguage","useEffect","attemptNumber","handlePlayPress","useCallback","setActive","togglePlayPause","handleTranslationToggle","toggle","jsxs","View","styles","container","largeContainer","children","header","jsx","Typography","title","VoiceTranscriptionHeaderActions","onPlayPress","onTranslationPress","VoiceTranscriptContent","text","isLoading","VoiceTranscriptionCollapsible","dropdown","exports","StyleSheet","create","position","top","left","width","maxHeight","minHeight","padding","boxShadow","borderRadius","backgroundColor","COLORS","NEUTRAL_1","overflow","height","flexDirection","justifyContent","alignItems","marginBottom","color","NEUTRAL_9","marginLeft"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/components/VoiceTranscription.tsx"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,mBAAA,GAAAX,OAAA;AACA,IAAAY,KAAA,GAAAZ,OAAA;AACA,IAAAa,6BAAA,GAAAb,OAAA;AACA,IAAAc,mCAAA,GAAAd,OAAA;AACA,IAAAe,gCAAA,GAAAf,OAAA;AAEA,IAAAgB,uBAAA,GAAAhB,OAAA;AACA,IAAAiB,8BAAA,GAAAjB,OAAA;AACA,IAAAkB,gCAAA,GAAAlB,OAAA;AAAmF,IAAAmB,WAAA,GAAAnB,OAAA;AAAA,SAAAO,uBAAAa,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAA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AC;EAEjC,MAAM,
|
|
1
|
+
{"version":3,"names":["_reactNativeUi","require","_effectorReact","_react","_interopRequireWildcard","_reactI18next","_reactNative","_reactNativeReanimated","_interopRequireDefault","_constants","_helpers","_types","_supportedLanguages","_i18n","_useVoiceTranscriptionEffects","_useVoiceTranscriptionAutoTranslate","_useVoiceTranscriptionAutoExpand","_VoiceTranscriptContent","_VoiceTranscriptionCollapsible","_VoiceTranscriptionHeaderActions","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","VoiceTranscriptionVariant","SMALL","useText","i18n","useTranslation","playerState","isLoadingTranscripts","loadedForAnswersKey","isTranslationActive","translations","isTranslating","useUnit","$playerState","loader","loadAllTranscripts","pending","$loadedKey","translation","$isActive","$translations","translate","activeAttempt","getActiveAttempt","isLargeVariant","LARGE","answersKey","useMemo","map","_id","audioFileId","join","useVoiceTranscriptionEffects","isContentReady","hasActiveAudio","undefined","activeTranscript","getTranscript","hasTranscriptText","NO_AUDIO_BE_MESSAGE","isActiveTranscriptLoading","transcriptLanguage","getTranscriptLanguage","isSourceSameAsTarget","resolveGoogleLanguageCode","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","useVoiceTranscriptionAutoTranslate","translationModel","useVoiceTranscriptionAutoExpand","targetLanguage","useEffect","attemptNumber","handlePlayPress","useCallback","setActive","togglePlayPause","handleTranslationToggle","toggle","jsxs","View","styles","container","largeContainer","children","header","jsx","Typography","title","VoiceTranscriptionHeaderActions","onPlayPress","onTranslationPress","VoiceTranscriptContent","text","isLoading","VoiceTranscriptionCollapsible","dropdown","exports","StyleSheet","create","position","top","left","width","maxHeight","minHeight","padding","boxShadow","borderRadius","backgroundColor","COLORS","NEUTRAL_1","overflow","height","flexDirection","justifyContent","alignItems","marginBottom","color","NEUTRAL_9","marginLeft"],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AkG,GAAA,EAACpG,8BAAA,CAAA6G,6BAA6B;MAC5BF,IAAI,EAAE3B,WAAY;MAClB4B,SAAS,EAAEtC,yBAAyB,IAAIS,oBAAqB;MAC7D+B,QAAQ,EAAErF,KAAK,CAACqF;IAAS,CAC1B,CACF;EAAA,CACY,CAAC;AAEpB,CAAC;AAAAC,OAAA,CAAAxF,kBAAA,GAAAA,kBAAA;AAED,MAAMwE,MAAM,GAAGiB,uBAAU,CAACC,MAAM,CAAC;EAC/BjB,SAAS,EAAE;IACTkB,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,EAAE;IACPC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,GAAG;IACVC,SAAS,EAAE,GAAG;IACdC,SAAS,EAAE,EAAE;IACbC,OAAO,EAAE,CAAC;IACVC,SAAS,EAAE,wCAAwC;IACnDC,YAAY,EAAE,EAAE;IAChBC,eAAe,EAAEC,qBAAM,CAACC,SAAS;IACjCC,QAAQ,EAAE;EACZ,CAAC;EACD7B,cAAc,EAAE;IACdoB,KAAK,EAAE,KAAK;IACZU,MAAM,EAAE;EACV,CAAC;EACD5B,MAAM,EAAE;IACN6B,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,eAAe;IAC/BC,UAAU,EAAE,QAAQ;IACpBV,OAAO,EAAE,CAAC;IACVW,YAAY,EAAE,CAAC;IACfJ,MAAM,EAAE;EACV,CAAC;EACDzB,KAAK,EAAE;IACL8B,KAAK,EAAER,qBAAM,CAACS,SAAS;IACvBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -18,13 +18,14 @@ const useVoiceTranscriptionEffects = ({
|
|
|
18
18
|
model.reinitializePlayer();
|
|
19
19
|
return () => model.cleanup();
|
|
20
20
|
}, [model]);
|
|
21
|
-
(0, _react.
|
|
21
|
+
(0, _react.useLayoutEffect)(() => {
|
|
22
|
+
model.loader.setTranscriptsLoaded(false);
|
|
22
23
|
model.resetPlayer();
|
|
23
24
|
}, [problemId]);
|
|
24
25
|
(0, _react.useEffect)(() => {
|
|
25
26
|
if (answersRef.current.some(answer => answer.audioFileId)) {
|
|
26
27
|
model.initializeWithAudios(answersRef.current);
|
|
27
|
-
model.loader.loadAllTranscripts();
|
|
28
|
+
model.loader.loadAllTranscripts(answersKey);
|
|
28
29
|
}
|
|
29
30
|
}, [model, answersKey]);
|
|
30
31
|
(0, _react.useEffect)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","useRef","current","useEffect","reinitializePlayer","cleanup","resetPlayer","some","answer","audioFileId","initializeWithAudios","
|
|
1
|
+
{"version":3,"names":["_react","require","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","useRef","current","useEffect","reinitializePlayer","cleanup","useLayoutEffect","loader","setTranscriptsLoaded","resetPlayer","some","answer","audioFileId","initializeWithAudios","loadAllTranscripts","stopAudio","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAYO,MAAMC,4BAA4B,GAAGA,CAAC;EAC3CC,KAAK;EACLC,OAAO;EACPC,UAAU;EACVC,SAAS;EACTC;AACM,CAAC,KAAK;EACZ,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAACL,OAAO,CAAC;EAClCI,UAAU,CAACE,OAAO,GAAGN,OAAO;EAE5B,IAAAO,gBAAS,EAAC,MAAM;IACdR,KAAK,CAACS,kBAAkB,CAAC,CAAC;IAC1B,OAAO,MAAMT,KAAK,CAACU,OAAO,CAAC,CAAC;EAC9B,CAAC,EAAE,CAACV,KAAK,CAAC,CAAC;EAEX,IAAAW,sBAAe,EAAC,MAAM;IACpBX,KAAK,CAACY,MAAM,CAACC,oBAAoB,CAAC,KAAK,CAAC;IACxCb,KAAK,CAACc,WAAW,CAAC,CAAC;EACrB,CAAC,EAAE,CAACX,SAAS,CAAC,CAAC;EAEf,IAAAK,gBAAS,EAAC,MAAM;IACd,IAAIH,UAAU,CAACE,OAAO,CAACQ,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,WAAW,CAAC,EAAE;MAC3DjB,KAAK,CAACkB,oBAAoB,CAACb,UAAU,CAACE,OAAO,CAAC;MAC9CP,KAAK,CAACY,MAAM,CAACO,kBAAkB,CAACjB,UAAU,CAAC;IAC7C;EACF,CAAC,EAAE,CAACF,KAAK,EAAEE,UAAU,CAAC,CAAC;EAEvB,IAAAM,gBAAS,EAAC,MAAM;IACdR,KAAK,CAACoB,SAAS,CAAC,CAAC;EACnB,CAAC,EAAE,CAAChB,aAAa,CAAC,CAAC;AACrB,CAAC;AAAAiB,OAAA,CAAAtB,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -10,33 +10,8 @@ class TranscriptionsDownloaderModel {
|
|
|
10
10
|
setTranscriptsLoaded = (0, _effector.createEvent)();
|
|
11
11
|
reset = (0, _effector.createEvent)();
|
|
12
12
|
$transcriptsLoaded = (0, _effector.restore)(this.setTranscriptsLoaded, false).reset(this.reset);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.api = api;
|
|
16
|
-
}
|
|
17
|
-
async fetchTranscriptWithRetry(audioFileId) {
|
|
18
|
-
for (let attempt = 0; attempt < _constants.TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
19
|
-
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
20
|
-
if (response.status === 'completed') {
|
|
21
|
-
return {
|
|
22
|
-
text: response.text,
|
|
23
|
-
language: response.language
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (response.status === 'failed') {
|
|
27
|
-
return {
|
|
28
|
-
text: _constants.NO_AUDIO_BE_MESSAGE
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (attempt < _constants.TRANSCRIPT_MAX_RETRIES - 1) {
|
|
32
|
-
await new Promise(resolve => setTimeout(resolve, _constants.TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
text: _constants.NO_AUDIO_BE_MESSAGE
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
loadAllTranscripts = (0, _effector.createEffect)(async () => {
|
|
13
|
+
$loadedKey = (0, _effector.createStore)('').reset(this.reset);
|
|
14
|
+
loadAllTranscripts = (0, _effector.createEffect)(async _contentKey => {
|
|
40
15
|
const attempts = this.collection.getAll();
|
|
41
16
|
const transcriptPromises = attempts.map(async item => {
|
|
42
17
|
if (this.collection.hasTranscript(item.attemptNumber)) {
|
|
@@ -66,6 +41,39 @@ class TranscriptionsDownloaderModel {
|
|
|
66
41
|
await Promise.all(transcriptPromises);
|
|
67
42
|
this.setTranscriptsLoaded(true);
|
|
68
43
|
});
|
|
44
|
+
constructor(collection, api) {
|
|
45
|
+
this.collection = collection;
|
|
46
|
+
this.api = api;
|
|
47
|
+
(0, _effector.sample)({
|
|
48
|
+
clock: this.loadAllTranscripts.done,
|
|
49
|
+
fn: ({
|
|
50
|
+
params
|
|
51
|
+
}) => params,
|
|
52
|
+
target: this.$loadedKey
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async fetchTranscriptWithRetry(audioFileId) {
|
|
56
|
+
for (let attempt = 0; attempt < _constants.TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
57
|
+
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
58
|
+
if (response.status === 'completed') {
|
|
59
|
+
return {
|
|
60
|
+
text: response.text,
|
|
61
|
+
language: response.language
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (response.status === 'failed') {
|
|
65
|
+
return {
|
|
66
|
+
text: _constants.NO_AUDIO_BE_MESSAGE
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (attempt < _constants.TRANSCRIPT_MAX_RETRIES - 1) {
|
|
70
|
+
await new Promise(resolve => setTimeout(resolve, _constants.TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
text: _constants.NO_AUDIO_BE_MESSAGE
|
|
75
|
+
};
|
|
76
|
+
}
|
|
69
77
|
getTranscript(attemptNumber) {
|
|
70
78
|
return this.collection.get(attemptNumber)?.transcript;
|
|
71
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_effector","require","_constants","TranscriptionsDownloaderModel","setTranscriptsLoaded","createEvent","reset","$transcriptsLoaded","restore","
|
|
1
|
+
{"version":3,"names":["_effector","require","_constants","TranscriptionsDownloaderModel","setTranscriptsLoaded","createEvent","reset","$transcriptsLoaded","restore","$loadedKey","createStore","loadAllTranscripts","createEffect","_contentKey","attempts","collection","getAll","transcriptPromises","map","item","hasTranscript","attemptNumber","update","transcriptLoading","text","language","fetchTranscriptWithRetry","audioFileId","transcript","transcriptLanguage","transcriptError","undefined","error","Error","message","Promise","all","constructor","api","sample","clock","done","fn","params","target","attempt","TRANSCRIPT_MAX_RETRIES","response","getAudioFileTranscript","status","NO_AUDIO_BE_MESSAGE","resolve","setTimeout","TRANSCRIPT_RETRY_INTERVAL_MS","getTranscript","get","getTranscriptLanguage","isTranscriptLoading","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsDownloaderModel.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AAMO,MAAME,6BAA6B,CAAC;EAIzBC,oBAAoB,GAAG,IAAAC,qBAAW,EAAU,CAAC;EAC7CC,KAAK,GAAG,IAAAD,qBAAW,EAAC,CAAC;EAErBE,kBAAkB,GAAG,IAAAC,iBAAO,EAAC,IAAI,CAACJ,oBAAoB,EAAE,KAAK,CAAC,CAACE,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EAChFG,UAAU,GAAG,IAAAC,qBAAW,EAAC,EAAE,CA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UAAU,CAACwC,GAAG,CAAClC,aAAa,CAAC,EAAEE,iBAAiB,IAAI,KAAK;EACvE;AACF;AAACmC,OAAA,CAAAvD,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
|
@@ -31,7 +31,7 @@ export const VoiceTranscription = ({
|
|
|
31
31
|
const {
|
|
32
32
|
i18n
|
|
33
33
|
} = useTranslation();
|
|
34
|
-
const [playerState, isLoadingTranscripts, isTranslationActive, translations, isTranslating] = useUnit([model.$playerState, model.loader.loadAllTranscripts.pending, model.translation.$isActive, model.translation.$translations, model.translation.translate.pending]);
|
|
34
|
+
const [playerState, isLoadingTranscripts, loadedForAnswersKey, isTranslationActive, translations, isTranslating] = useUnit([model.$playerState, model.loader.loadAllTranscripts.pending, model.loader.$loadedKey, model.translation.$isActive, model.translation.$translations, model.translation.translate.pending]);
|
|
35
35
|
const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount);
|
|
36
36
|
const isLargeVariant = variant === VoiceTranscriptionVariant.LARGE;
|
|
37
37
|
const answersKey = useMemo(() => answers.map(a => `${a._id}:${a.audioFileId ?? ''}`).join(','), [answers]);
|
|
@@ -42,11 +42,12 @@ export const VoiceTranscription = ({
|
|
|
42
42
|
problemId,
|
|
43
43
|
activeAttempt
|
|
44
44
|
});
|
|
45
|
+
const isContentReady = loadedForAnswersKey === answersKey;
|
|
45
46
|
const hasActiveAudio = activeAttempt !== null && answers?.[activeAttempt - 1]?.audioFileId !== undefined;
|
|
46
|
-
const activeTranscript = activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null;
|
|
47
|
+
const activeTranscript = isContentReady && activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null;
|
|
47
48
|
const hasTranscriptText = !!activeTranscript && activeTranscript !== NO_AUDIO_BE_MESSAGE;
|
|
48
49
|
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript;
|
|
49
|
-
const transcriptLanguage = activeAttempt !== null ? model.loader.getTranscriptLanguage(activeAttempt) : undefined;
|
|
50
|
+
const transcriptLanguage = isContentReady && activeAttempt !== null ? model.loader.getTranscriptLanguage(activeAttempt) : undefined;
|
|
50
51
|
const isSourceSameAsTarget = !!transcriptLanguage && resolveGoogleLanguageCode(transcriptLanguage) === resolveGoogleLanguageCode(i18n.language);
|
|
51
52
|
const canTranslate = hasTranscriptText && !isSourceSameAsTarget;
|
|
52
53
|
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Typography","COLORS","useUnit","React","useCallback","useEffect","useMemo","useTranslation","StyleSheet","View","Animated","NO_AUDIO_BE_MESSAGE","getActiveAttempt","VoiceTranscriptionVariant","resolveGoogleLanguageCode","useText","useVoiceTranscriptionEffects","useVoiceTranscriptionAutoTranslate","useVoiceTranscriptionAutoExpand","VoiceTranscriptContent","VoiceTranscriptionCollapsible","VoiceTranscriptionHeaderActions","jsx","_jsx","jsxs","_jsxs","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","SMALL","t","i18n","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","$playerState","loader","loadAllTranscripts","pending","translation","$isActive","$translations","translate","activeAttempt","isLargeVariant","LARGE","answersKey","map","a","_id","audioFileId","join","hasActiveAudio","undefined","activeTranscript","getTranscript","hasTranscriptText","isActiveTranscriptLoading","transcriptLanguage","getTranscriptLanguage","isSourceSameAsTarget","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","translationModel","targetLanguage","attemptNumber","handlePlayPress","setActive","togglePlayPause","handleTranslationToggle","toggle","styles","container","largeContainer","children","header","title","onPlayPress","onTranslationPress","text","isLoading","dropdown","create","position","top","left","width","maxHeight","minHeight","padding","boxShadow","borderRadius","backgroundColor","NEUTRAL_1","overflow","height","flexDirection","justifyContent","alignItems","marginBottom","color","NEUTRAL_9","marginLeft"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/components/VoiceTranscription.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,MAAM,QAAQ,4BAA4B;AAC/D,SAASC,OAAO,QAAQ,gBAAgB;AACxC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC9D,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAAoBC,UAAU,EAAEC,IAAI,QAAmB,cAAc;AACrE,OAAOC,QAAQ,MAAM,yBAAyB;AAC9C,SAASC,mBAAmB,QAAQ,oBAAiB;AACrD,SAASC,gBAAgB,QAAQ,kBAAe;AAChD,SAAsBC,yBAAyB,QAAQ,gBAAa;AACpE,SAASC,yBAAyB,QAAQ,6DAA0D;AACpG,SAASC,OAAO,QAAQ,0BAAuB;AAC/C,SAASC,4BAA4B,QAAQ,0CAAuC;AACpF,SAASC,kCAAkC,QAAQ,gDAA6C;AAChG,SAASC,+BAA+B,QAAQ,6CAA0C;AAE1F,SAASC,sBAAsB,QAAQ,6BAA0B;AACjE,SAASC,6BAA6B,QAAQ,oCAAiC;AAC/E,SAASC,+BAA+B,QAAQ,sCAAmC;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAYnF,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EACjCC,KAAK;EACLC,KAAK;EACLC,OAAO;EACPC,aAAa;EACbC,aAAa;EACbC,SAAS;EACTC,OAAO,GAAGpB,yBAAyB,CAACqB;AACb,CAAC,KAAK;EAC7B,MAAMC,CAAC,GAAGpB,OAAO,CAAC,CAAC;EACnB,MAAM;IAAEqB;EAAK,CAAC,GAAG7B,cAAc,CAAC,CAAC;EAEjC,MAAM,
|
|
1
|
+
{"version":3,"names":["Typography","COLORS","useUnit","React","useCallback","useEffect","useMemo","useTranslation","StyleSheet","View","Animated","NO_AUDIO_BE_MESSAGE","getActiveAttempt","VoiceTranscriptionVariant","resolveGoogleLanguageCode","useText","useVoiceTranscriptionEffects","useVoiceTranscriptionAutoTranslate","useVoiceTranscriptionAutoExpand","VoiceTranscriptContent","VoiceTranscriptionCollapsible","VoiceTranscriptionHeaderActions","jsx","_jsx","jsxs","_jsxs","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","SMALL","t","i18n","playerState","isLoadingTranscripts","loadedForAnswersKey","isTranslationActive","translations","isTranslating","$playerState","loader","loadAllTranscripts","pending","$loadedKey","translation","$isActive","$translations","translate","activeAttempt","isLargeVariant","LARGE","answersKey","map","a","_id","audioFileId","join","isContentReady","hasActiveAudio","undefined","activeTranscript","getTranscript","hasTranscriptText","isActiveTranscriptLoading","transcriptLanguage","getTranscriptLanguage","isSourceSameAsTarget","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","translationModel","targetLanguage","attemptNumber","handlePlayPress","setActive","togglePlayPause","handleTranslationToggle","toggle","styles","container","largeContainer","children","header","title","onPlayPress","onTranslationPress","text","isLoading","dropdown","create","position","top","left","width","maxHeight","minHeight","padding","boxShadow","borderRadius","backgroundColor","NEUTRAL_1","overflow","height","flexDirection","justifyContent","alignItems","marginBottom","color","NEUTRAL_9","marginLeft"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/components/VoiceTranscription.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,MAAM,QAAQ,4BAA4B;AAC/D,SAASC,OAAO,QAAQ,gBAAgB;AACxC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC9D,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAAoBC,UAAU,EAAEC,IAAI,QAAmB,cAAc;AACrE,OAAOC,QAAQ,MAAM,yBAAyB;AAC9C,SAASC,mBAAmB,QAAQ,oBAAiB;AACrD,SAASC,gBAAgB,QAAQ,kBAAe;AAChD,SAAsBC,yBAAyB,QAAQ,gBAAa;AACpE,SAASC,yBAAyB,QAAQ,6DAA0D;AACpG,SAASC,OAAO,QAAQ,0BAAuB;AAC/C,SAASC,4BAA4B,QAAQ,0CAAuC;AACpF,SAASC,kCA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cAAc,EAAE,eAAe;IAC/BC,UAAU,EAAE,QAAQ;IACpBT,OAAO,EAAE,CAAC;IACVU,YAAY,EAAE,CAAC;IACfJ,MAAM,EAAE;EACV,CAAC;EACDnB,KAAK,EAAE;IACLwB,KAAK,EAAEjH,MAAM,CAACkH,SAAS;IACvBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef } from 'react';
|
|
4
4
|
export const useVoiceTranscriptionEffects = ({
|
|
5
5
|
model,
|
|
6
6
|
answers,
|
|
@@ -14,13 +14,14 @@ export const useVoiceTranscriptionEffects = ({
|
|
|
14
14
|
model.reinitializePlayer();
|
|
15
15
|
return () => model.cleanup();
|
|
16
16
|
}, [model]);
|
|
17
|
-
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
model.loader.setTranscriptsLoaded(false);
|
|
18
19
|
model.resetPlayer();
|
|
19
20
|
}, [problemId]);
|
|
20
21
|
useEffect(() => {
|
|
21
22
|
if (answersRef.current.some(answer => answer.audioFileId)) {
|
|
22
23
|
model.initializeWithAudios(answersRef.current);
|
|
23
|
-
model.loader.loadAllTranscripts();
|
|
24
|
+
model.loader.loadAllTranscripts(answersKey);
|
|
24
25
|
}
|
|
25
26
|
}, [model, answersKey]);
|
|
26
27
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","current","reinitializePlayer","cleanup","resetPlayer","some","answer","audioFileId","initializeWithAudios","
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useRef","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","current","reinitializePlayer","cleanup","loader","setTranscriptsLoaded","resetPlayer","some","answer","audioFileId","initializeWithAudios","loadAllTranscripts","stopAudio"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAY1D,OAAO,MAAMC,4BAA4B,GAAGA,CAAC;EAC3CC,KAAK;EACLC,OAAO;EACPC,UAAU;EACVC,SAAS;EACTC;AACM,CAAC,KAAK;EACZ,MAAMC,UAAU,GAAGP,MAAM,CAACG,OAAO,CAAC;EAClCI,UAAU,CAACC,OAAO,GAAGL,OAAO;EAE5BL,SAAS,CAAC,MAAM;IACdI,KAAK,CAACO,kBAAkB,CAAC,CAAC;IAC1B,OAAO,MAAMP,KAAK,CAACQ,OAAO,CAAC,CAAC;EAC9B,CAAC,EAAE,CAACR,KAAK,CAAC,CAAC;EAEXH,eAAe,CAAC,MAAM;IACpBG,KAAK,CAACS,MAAM,CAACC,oBAAoB,CAAC,KAAK,CAAC;IACxCV,KAAK,CAACW,WAAW,CAAC,CAAC;EACrB,CAAC,EAAE,CAACR,SAAS,CAAC,CAAC;EAEfP,SAAS,CAAC,MAAM;IACd,IAAIS,UAAU,CAACC,OAAO,CAACM,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,WAAW,CAAC,EAAE;MAC3Dd,KAAK,CAACe,oBAAoB,CAACV,UAAU,CAACC,OAAO,CAAC;MAC9CN,KAAK,CAACS,MAAM,CAACO,kBAAkB,CAACd,UAAU,CAAC;IAC7C;EACF,CAAC,EAAE,CAACF,KAAK,EAAEE,UAAU,CAAC,CAAC;EAEvBN,SAAS,CAAC,MAAM;IACdI,KAAK,CAACiB,SAAS,CAAC,CAAC;EACnB,CAAC,EAAE,CAACb,aAAa,CAAC,CAAC;AACrB,CAAC","ignoreList":[]}
|
|
@@ -1,38 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { createEffect, createEvent, restore } from 'effector';
|
|
3
|
+
import { createEffect, createEvent, createStore, restore, sample } from 'effector';
|
|
4
4
|
import { NO_AUDIO_BE_MESSAGE, TRANSCRIPT_MAX_RETRIES, TRANSCRIPT_RETRY_INTERVAL_MS } from "../../constants.js";
|
|
5
5
|
export class TranscriptionsDownloaderModel {
|
|
6
6
|
setTranscriptsLoaded = createEvent();
|
|
7
7
|
reset = createEvent();
|
|
8
8
|
$transcriptsLoaded = restore(this.setTranscriptsLoaded, false).reset(this.reset);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.api = api;
|
|
12
|
-
}
|
|
13
|
-
async fetchTranscriptWithRetry(audioFileId) {
|
|
14
|
-
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
15
|
-
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
16
|
-
if (response.status === 'completed') {
|
|
17
|
-
return {
|
|
18
|
-
text: response.text,
|
|
19
|
-
language: response.language
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
if (response.status === 'failed') {
|
|
23
|
-
return {
|
|
24
|
-
text: NO_AUDIO_BE_MESSAGE
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
28
|
-
await new Promise(resolve => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
text: NO_AUDIO_BE_MESSAGE
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
loadAllTranscripts = createEffect(async () => {
|
|
9
|
+
$loadedKey = createStore('').reset(this.reset);
|
|
10
|
+
loadAllTranscripts = createEffect(async _contentKey => {
|
|
36
11
|
const attempts = this.collection.getAll();
|
|
37
12
|
const transcriptPromises = attempts.map(async item => {
|
|
38
13
|
if (this.collection.hasTranscript(item.attemptNumber)) {
|
|
@@ -62,6 +37,39 @@ export class TranscriptionsDownloaderModel {
|
|
|
62
37
|
await Promise.all(transcriptPromises);
|
|
63
38
|
this.setTranscriptsLoaded(true);
|
|
64
39
|
});
|
|
40
|
+
constructor(collection, api) {
|
|
41
|
+
this.collection = collection;
|
|
42
|
+
this.api = api;
|
|
43
|
+
sample({
|
|
44
|
+
clock: this.loadAllTranscripts.done,
|
|
45
|
+
fn: ({
|
|
46
|
+
params
|
|
47
|
+
}) => params,
|
|
48
|
+
target: this.$loadedKey
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async fetchTranscriptWithRetry(audioFileId) {
|
|
52
|
+
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
53
|
+
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
54
|
+
if (response.status === 'completed') {
|
|
55
|
+
return {
|
|
56
|
+
text: response.text,
|
|
57
|
+
language: response.language
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (response.status === 'failed') {
|
|
61
|
+
return {
|
|
62
|
+
text: NO_AUDIO_BE_MESSAGE
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
66
|
+
await new Promise(resolve => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
text: NO_AUDIO_BE_MESSAGE
|
|
71
|
+
};
|
|
72
|
+
}
|
|
65
73
|
getTranscript(attemptNumber) {
|
|
66
74
|
return this.collection.get(attemptNumber)?.transcript;
|
|
67
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEffect","createEvent","restore","NO_AUDIO_BE_MESSAGE","TRANSCRIPT_MAX_RETRIES","TRANSCRIPT_RETRY_INTERVAL_MS","TranscriptionsDownloaderModel","setTranscriptsLoaded","reset","$transcriptsLoaded","
|
|
1
|
+
{"version":3,"names":["createEffect","createEvent","createStore","restore","sample","NO_AUDIO_BE_MESSAGE","TRANSCRIPT_MAX_RETRIES","TRANSCRIPT_RETRY_INTERVAL_MS","TranscriptionsDownloaderModel","setTranscriptsLoaded","reset","$transcriptsLoaded","$loadedKey","loadAllTranscripts","_contentKey","attempts","collection","getAll","transcriptPromises","map","item","hasTranscript","attemptNumber","update","transcriptLoading","text","language","fetchTranscriptWithRetry","audioFileId","transcript","transcriptLanguage","transcriptError","undefined","error","Error","message","Promise","all","constructor","api","clock","done","fn","params","target","attempt","response","getAudioFileTranscript","status","resolve","setTimeout","getTranscript","get","getTranscriptLanguage","isTranscriptLoading"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsDownloaderModel.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,EAAEC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,UAAU;AAGlF,SACEC,mBAAmB,EACnBC,sBAAsB,EACtBC,4BAA4B,QACvB,oBAAiB;AAExB,OAAO,MAAMC,6BAA6B,CAAC;EAIzBC,oBAAoB,GAAGR,WAAW,CAAU,CAAC;EAC7CS,KAAK,GAAGT,WAAW,CAAC,CAAC;EAErBU,kBAAkB,GAAGR,OAAO,CAAC,IAAI,CAACM,oBAAoB,EAAE,KAAK,CAAC,CAACC,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EAChFE,UAAU,GAAGV,WAAW,CAAC,EAAE,CAAC,CAACQ,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EAE9CG,kBAAkB,GAAGb,YAAY,CAAC,MAAOc,WAAmB,IAAK;IAC/E,MAAMC,QAAQ,GAAG,IAAI,CAACC,UAAU,CAACC,MAAM,CAAC,CAAC;IAEzC,MAAMC,kBAAkB,GAAGH,QAAQ,CAACI,GAAG,CAAC,MAAOC,IAAI,IAAK;MACtD,IAAI,IAAI,CAACJ,UAAU,CAACK,aAAa,CAACD,IAAI,CAACE,aAAa,CAAC,EAAE;QACrD;MACF;MAEA,IAAI,CAACN,UAAU,CAACO,MAAM,CAACH,IAAI,CAACE,aAAa,EAAE;QAA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sBAAsB,CAACnB,WAAW,CAAC;MAEnE,IAAIkB,QAAQ,CAACE,MAAM,KAAK,WAAW,EAAE;QACnC,OAAO;UAAEvB,IAAI,EAAEqB,QAAQ,CAACrB,IAAI;UAAEC,QAAQ,EAAEoB,QAAQ,CAACpB;QAAS,CAAC;MAC7D;MAEA,IAAIoB,QAAQ,CAACE,MAAM,KAAK,QAAQ,EAAE;QAChC,OAAO;UAAEvB,IAAI,EAAEpB;QAAoB,CAAC;MACtC;MAEA,IAAIwC,OAAO,GAAGvC,sBAAsB,GAAG,CAAC,EAAE;QACxC,MAAM,IAAI8B,OAAO,CAAEa,OAAO,IAAKC,UAAU,CAACD,OAAO,EAAE1C,4BAA4B,CAAC,CAAC;MACnF;IACF;IACA,OAAO;MAAEkB,IAAI,EAAEpB;IAAoB,CAAC;EACtC;EAEO8C,aAAaA,CAAC7B,aAAqB,EAAsB;IAC9D,OAAO,IAAI,CAACN,UAAU,CAACoC,GAAG,CAAC9B,aAAa,CAAC,EAAEO,UAAU;EACvD;EAEOwB,qBAAqBA,CAAC/B,aAAqB,EAAsB;IACtE,OAAO,IAAI,CAACN,UAAU,CAACoC,GAAG,CAAC9B,aAAa,CAAC,EAAEQ,kBAAkB;EAC/D;EAEOwB,mBAAmBA,CAAChC,aAAqB,EAAW;IACzD,OAAO,IAAI,CAACN,UAAU,CAACoC,GAAG,CAAC9B,aAAa,CAAC,EAAEE,iBAAiB,IAAI,KAAK;EACvE;AACF","ignoreList":[]}
|
package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTranscription.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/components/VoiceTranscription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAIrE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAMpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAK3C,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,kBAAkB,iFAQ5B,uBAAuB,
|
|
1
|
+
{"version":3,"file":"VoiceTranscription.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/components/VoiceTranscription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAIrE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAMpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAK3C,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,kBAAkB,iFAQ5B,uBAAuB,sBA4HzB,CAAA"}
|
package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,4BAA4B,8DAMtC,MAAM,
|
|
1
|
+
{"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,4BAA4B,8DAMtC,MAAM,SAwBR,CAAA"}
|
package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ export declare class TranscriptionsDownloaderModel {
|
|
|
6
6
|
readonly setTranscriptsLoaded: import("effector").EventCallable<boolean>;
|
|
7
7
|
readonly reset: import("effector").EventCallable<void>;
|
|
8
8
|
readonly $transcriptsLoaded: import("effector").StoreWritable<boolean>;
|
|
9
|
+
readonly $loadedKey: import("effector").StoreWritable<string>;
|
|
10
|
+
readonly loadAllTranscripts: import("effector").Effect<string, void, Error>;
|
|
9
11
|
constructor(collection: VoiceTranscriptionsCollection, api: VoicePlayerApi);
|
|
10
12
|
private fetchTranscriptWithRetry;
|
|
11
|
-
readonly loadAllTranscripts: import("effector").Effect<void, void, Error>;
|
|
12
13
|
getTranscript(attemptNumber: number): string | undefined;
|
|
13
14
|
getTranscriptLanguage(attemptNumber: number): string | undefined;
|
|
14
15
|
isTranscriptLoading(attemptNumber: number): boolean;
|
package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranscriptionsDownloaderModel.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/TranscriptionsDownloaderModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAO5C,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IAEpC,SAAgB,oBAAoB,4CAAyB;IAC7D,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,kBAAkB,4CAA8D;
|
|
1
|
+
{"version":3,"file":"TranscriptionsDownloaderModel.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/TranscriptionsDownloaderModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAO5C,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IAEpC,SAAgB,oBAAoB,4CAAyB;IAC7D,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,kBAAkB,4CAA8D;IAChG,SAAgB,UAAU,2CAAoC;IAE9D,SAAgB,kBAAkB,iDA6BhC;gBAEU,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;YAW5D,wBAAwB;IAqB/B,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIxD,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIhE,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;CAG3D"}
|
package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTranscription.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/components/VoiceTranscription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAIrE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAMpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAK3C,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,kBAAkB,iFAQ5B,uBAAuB,
|
|
1
|
+
{"version":3,"file":"VoiceTranscription.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/components/VoiceTranscription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAIrE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAMpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAK3C,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,kBAAkB,iFAQ5B,uBAAuB,sBA4HzB,CAAA"}
|
package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,4BAA4B,8DAMtC,MAAM,
|
|
1
|
+
{"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,4BAA4B,8DAMtC,MAAM,SAwBR,CAAA"}
|
package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ export declare class TranscriptionsDownloaderModel {
|
|
|
6
6
|
readonly setTranscriptsLoaded: import("effector").EventCallable<boolean>;
|
|
7
7
|
readonly reset: import("effector").EventCallable<void>;
|
|
8
8
|
readonly $transcriptsLoaded: import("effector").StoreWritable<boolean>;
|
|
9
|
+
readonly $loadedKey: import("effector").StoreWritable<string>;
|
|
10
|
+
readonly loadAllTranscripts: import("effector").Effect<string, void, Error>;
|
|
9
11
|
constructor(collection: VoiceTranscriptionsCollection, api: VoicePlayerApi);
|
|
10
12
|
private fetchTranscriptWithRetry;
|
|
11
|
-
readonly loadAllTranscripts: import("effector").Effect<void, void, Error>;
|
|
12
13
|
getTranscript(attemptNumber: number): string | undefined;
|
|
13
14
|
getTranscriptLanguage(attemptNumber: number): string | undefined;
|
|
14
15
|
isTranscriptLoading(attemptNumber: number): boolean;
|
package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranscriptionsDownloaderModel.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/TranscriptionsDownloaderModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAO5C,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IAEpC,SAAgB,oBAAoB,4CAAyB;IAC7D,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,kBAAkB,4CAA8D;
|
|
1
|
+
{"version":3,"file":"TranscriptionsDownloaderModel.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/TranscriptionsDownloaderModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAO5C,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IAEpC,SAAgB,oBAAoB,4CAAyB;IAC7D,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,kBAAkB,4CAA8D;IAChG,SAAgB,UAAU,2CAAoC;IAE9D,SAAgB,kBAAkB,iDA6BhC;gBAEU,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;YAW5D,wBAAwB;IAqB/B,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIxD,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIhE,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;CAG3D"}
|
package/package.json
CHANGED
|
@@ -39,14 +39,21 @@ export const VoiceTranscription = ({
|
|
|
39
39
|
const t = useText()
|
|
40
40
|
const { i18n } = useTranslation()
|
|
41
41
|
|
|
42
|
-
const [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
const [
|
|
43
|
+
playerState,
|
|
44
|
+
isLoadingTranscripts,
|
|
45
|
+
loadedForAnswersKey,
|
|
46
|
+
isTranslationActive,
|
|
47
|
+
translations,
|
|
48
|
+
isTranslating,
|
|
49
|
+
] = useUnit([
|
|
50
|
+
model.$playerState,
|
|
51
|
+
model.loader.loadAllTranscripts.pending,
|
|
52
|
+
model.loader.$loadedKey,
|
|
53
|
+
model.translation.$isActive,
|
|
54
|
+
model.translation.$translations,
|
|
55
|
+
model.translation.translate.pending,
|
|
56
|
+
])
|
|
50
57
|
|
|
51
58
|
const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount)
|
|
52
59
|
const isLargeVariant = variant === VoiceTranscriptionVariant.LARGE
|
|
@@ -58,15 +65,20 @@ export const VoiceTranscription = ({
|
|
|
58
65
|
|
|
59
66
|
useVoiceTranscriptionEffects({ model, answers, answersKey, problemId, activeAttempt })
|
|
60
67
|
|
|
68
|
+
const isContentReady = loadedForAnswersKey === answersKey
|
|
69
|
+
|
|
61
70
|
const hasActiveAudio =
|
|
62
71
|
activeAttempt !== null && answers?.[activeAttempt - 1]?.audioFileId !== undefined
|
|
63
72
|
|
|
64
|
-
const activeTranscript =
|
|
73
|
+
const activeTranscript =
|
|
74
|
+
isContentReady && activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null
|
|
65
75
|
const hasTranscriptText = !!activeTranscript && activeTranscript !== NO_AUDIO_BE_MESSAGE
|
|
66
76
|
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript
|
|
67
77
|
|
|
68
78
|
const transcriptLanguage =
|
|
69
|
-
activeAttempt !== null
|
|
79
|
+
isContentReady && activeAttempt !== null
|
|
80
|
+
? model.loader.getTranscriptLanguage(activeAttempt)
|
|
81
|
+
: undefined
|
|
70
82
|
const isSourceSameAsTarget =
|
|
71
83
|
!!transcriptLanguage &&
|
|
72
84
|
resolveGoogleLanguageCode(transcriptLanguage) === resolveGoogleLanguageCode(i18n.language)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react'
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef } from 'react'
|
|
2
2
|
import { AnswerAudio } from '../../types'
|
|
3
3
|
import { VoicePlayerModel } from '../model'
|
|
4
4
|
|
|
@@ -25,14 +25,15 @@ export const useVoiceTranscriptionEffects = ({
|
|
|
25
25
|
return () => model.cleanup()
|
|
26
26
|
}, [model])
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
useLayoutEffect(() => {
|
|
29
|
+
model.loader.setTranscriptsLoaded(false)
|
|
29
30
|
model.resetPlayer()
|
|
30
31
|
}, [problemId])
|
|
31
32
|
|
|
32
33
|
useEffect(() => {
|
|
33
34
|
if (answersRef.current.some((answer) => answer.audioFileId)) {
|
|
34
35
|
model.initializeWithAudios(answersRef.current)
|
|
35
|
-
model.loader.loadAllTranscripts()
|
|
36
|
+
model.loader.loadAllTranscripts(answersKey)
|
|
36
37
|
}
|
|
37
38
|
}, [model, answersKey])
|
|
38
39
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createEffect, createEvent, restore } from 'effector'
|
|
1
|
+
import { createEffect, createEvent, createStore, restore, sample } from 'effector'
|
|
2
2
|
import { VoiceTranscriptionsCollection } from './VoiceTranscriptionsCollection'
|
|
3
3
|
import { VoicePlayerApi } from '../../types'
|
|
4
4
|
import {
|
|
@@ -15,34 +15,9 @@ export class TranscriptionsDownloaderModel {
|
|
|
15
15
|
public readonly reset = createEvent()
|
|
16
16
|
|
|
17
17
|
public readonly $transcriptsLoaded = restore(this.setTranscriptsLoaded, false).reset(this.reset)
|
|
18
|
+
public readonly $loadedKey = createStore('').reset(this.reset)
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
this.collection = collection
|
|
21
|
-
this.api = api
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private async fetchTranscriptWithRetry(
|
|
25
|
-
audioFileId: string,
|
|
26
|
-
): Promise<{ text: string; language?: string }> {
|
|
27
|
-
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
28
|
-
const response = await this.api.getAudioFileTranscript(audioFileId)
|
|
29
|
-
|
|
30
|
-
if (response.status === 'completed') {
|
|
31
|
-
return { text: response.text, language: response.language }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (response.status === 'failed') {
|
|
35
|
-
return { text: NO_AUDIO_BE_MESSAGE }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
39
|
-
await new Promise((resolve) => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS))
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return { text: NO_AUDIO_BE_MESSAGE }
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public readonly loadAllTranscripts = createEffect(async () => {
|
|
20
|
+
public readonly loadAllTranscripts = createEffect(async (_contentKey: string) => {
|
|
46
21
|
const attempts = this.collection.getAll()
|
|
47
22
|
|
|
48
23
|
const transcriptPromises = attempts.map(async (item) => {
|
|
@@ -73,6 +48,38 @@ export class TranscriptionsDownloaderModel {
|
|
|
73
48
|
this.setTranscriptsLoaded(true)
|
|
74
49
|
})
|
|
75
50
|
|
|
51
|
+
constructor(collection: VoiceTranscriptionsCollection, api: VoicePlayerApi) {
|
|
52
|
+
this.collection = collection
|
|
53
|
+
this.api = api
|
|
54
|
+
|
|
55
|
+
sample({
|
|
56
|
+
clock: this.loadAllTranscripts.done,
|
|
57
|
+
fn: ({ params }) => params,
|
|
58
|
+
target: this.$loadedKey,
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private async fetchTranscriptWithRetry(
|
|
63
|
+
audioFileId: string,
|
|
64
|
+
): Promise<{ text: string; language?: string }> {
|
|
65
|
+
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
66
|
+
const response = await this.api.getAudioFileTranscript(audioFileId)
|
|
67
|
+
|
|
68
|
+
if (response.status === 'completed') {
|
|
69
|
+
return { text: response.text, language: response.language }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (response.status === 'failed') {
|
|
73
|
+
return { text: NO_AUDIO_BE_MESSAGE }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
77
|
+
await new Promise((resolve) => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { text: NO_AUDIO_BE_MESSAGE }
|
|
81
|
+
}
|
|
82
|
+
|
|
76
83
|
public getTranscript(attemptNumber: number): string | undefined {
|
|
77
84
|
return this.collection.get(attemptNumber)?.transcript
|
|
78
85
|
}
|