@magmamath/students-features 1.3.23-rc.3 → 1.3.23-rc.4
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 +24 -9
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +15 -4
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +2 -1
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js +33 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +1 -1
- package/dist/commonjs/features/voice/types.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscription.js +25 -10
- package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -1
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +15 -4
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js +2 -1
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js +34 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +1 -1
- package/dist/module/features/voice/types.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/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts +18 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/types.d.ts +16 -0
- package/dist/typescript/commonjs/features/voice/types.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/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts +18 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/types.d.ts +16 -0
- package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/voice/playing/components/VoiceTranscription.tsx +40 -11
- package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +8 -5
- package/src/features/voice/playing/model/VoicePlayer.model.ts +3 -1
- package/src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts +51 -1
- package/src/features/voice/types.ts +17 -0
|
@@ -7,6 +7,7 @@ exports.VoiceTranscription = void 0;
|
|
|
7
7
|
var _reactNativeUi = require("@magmamath/react-native-ui");
|
|
8
8
|
var _effectorReact = require("effector-react");
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactI18next = require("react-i18next");
|
|
10
11
|
var _reactNative = require("react-native");
|
|
11
12
|
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
|
|
12
13
|
var _constants = require("../../constants.js");
|
|
@@ -31,7 +32,10 @@ const VoiceTranscription = ({
|
|
|
31
32
|
variant = _types.VoiceTranscriptionVariant.SMALL
|
|
32
33
|
}) => {
|
|
33
34
|
const t = (0, _i18n.useText)();
|
|
34
|
-
const
|
|
35
|
+
const {
|
|
36
|
+
i18n
|
|
37
|
+
} = (0, _reactI18next.useTranslation)();
|
|
38
|
+
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]);
|
|
35
39
|
const activeAttempt = (0, _helpers.getActiveAttempt)(attemptOffset, attemptsCount);
|
|
36
40
|
const isLargeVariant = variant === _types.VoiceTranscriptionVariant.LARGE;
|
|
37
41
|
const answersKey = (0, _react.useMemo)(() => answers.map(a => `${a._id}:${a.audioFileId ?? ''}`).join(','), [answers]);
|
|
@@ -42,11 +46,22 @@ const VoiceTranscription = ({
|
|
|
42
46
|
problemId,
|
|
43
47
|
activeAttempt
|
|
44
48
|
});
|
|
45
|
-
const
|
|
49
|
+
const hasActiveAudio = activeAttempt !== null && answers?.[activeAttempt - 1]?.audioFileId !== undefined;
|
|
46
50
|
const activeTranscript = activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null;
|
|
47
51
|
const hasTranscriptText = !!activeTranscript && activeTranscript !== _constants.NO_AUDIO_BE_MESSAGE;
|
|
48
|
-
const isActiveTranscriptLoading = isLoadingTranscripts &&
|
|
49
|
-
const
|
|
52
|
+
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript;
|
|
53
|
+
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined;
|
|
54
|
+
const showTranslation = isTranslationActive && hasTranscriptText;
|
|
55
|
+
const isTranslationLoading = showTranslation && !cachedTranslation && isTranslating;
|
|
56
|
+
const displayText = showTranslation ? cachedTranslation ?? activeTranscript : hasTranscriptText ? activeTranscript : t('voice.transcriptNotAvailable');
|
|
57
|
+
(0, _react.useEffect)(() => {
|
|
58
|
+
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
59
|
+
model.translation.translate({
|
|
60
|
+
attemptNumber: activeAttempt,
|
|
61
|
+
targetLanguage: i18n.language
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, [showTranslation, activeAttempt, cachedTranslation, isTranslating, i18n.language, model]);
|
|
50
65
|
const handlePlayPress = (0, _react.useCallback)(() => {
|
|
51
66
|
if (activeAttempt) {
|
|
52
67
|
model.translation.setActive(false);
|
|
@@ -64,7 +79,7 @@ const VoiceTranscription = ({
|
|
|
64
79
|
style: styles.title,
|
|
65
80
|
variant: "h7",
|
|
66
81
|
children: t('voice.transcriptions')
|
|
67
|
-
}),
|
|
82
|
+
}), hasActiveAudio && /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceTranscriptionHeaderActions.VoiceTranscriptionHeaderActions, {
|
|
68
83
|
playerState: playerState,
|
|
69
84
|
isTranslationActive: isTranslationActive,
|
|
70
85
|
canTranslate: hasTranscriptText,
|
|
@@ -72,11 +87,11 @@ const VoiceTranscription = ({
|
|
|
72
87
|
onTranslationPress: handleTranslationToggle
|
|
73
88
|
})]
|
|
74
89
|
}), isLargeVariant ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceTranscriptContent.VoiceTranscriptContent, {
|
|
75
|
-
text:
|
|
76
|
-
isLoading: isActiveTranscriptLoading
|
|
90
|
+
text: displayText,
|
|
91
|
+
isLoading: isActiveTranscriptLoading || isTranslationLoading
|
|
77
92
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceTranscriptionCollapsible.VoiceTranscriptionCollapsible, {
|
|
78
|
-
text:
|
|
79
|
-
isLoading: isActiveTranscriptLoading,
|
|
93
|
+
text: displayText,
|
|
94
|
+
isLoading: isActiveTranscriptLoading || isTranslationLoading,
|
|
80
95
|
dropdown: model.dropdown
|
|
81
96
|
})]
|
|
82
97
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeUi","require","_effectorReact","_react","_interopRequireWildcard","_reactNative","_reactNativeReanimated","_interopRequireDefault","_constants","_helpers","_types","_i18n","_useVoiceTranscriptionEffects","_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","playerState","isLoadingTranscripts","isTranslationActive","useUnit","$playerState","loader","loadAllTranscripts","pending","translation","$isActive","activeAttempt","getActiveAttempt","isLargeVariant","LARGE","answersKey","useMemo","map","_id","audioFileId","join","useVoiceTranscriptionEffects","
|
|
1
|
+
{"version":3,"names":["_reactNativeUi","require","_effectorReact","_react","_interopRequireWildcard","_reactI18next","_reactNative","_reactNativeReanimated","_interopRequireDefault","_constants","_helpers","_types","_i18n","_useVoiceTranscriptionEffects","_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","cachedTranslation","showTranslation","isTranslationLoading","displayText","useEffect","attemptNumber","targetLanguage","language","handlePlayPress","useCallback","setActive","togglePlayPause","handleTranslationToggle","toggle","jsxs","View","styles","container","largeContainer","children","header","jsx","Typography","title","VoiceTranscriptionHeaderActions","canTranslate","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,KAAA,GAAAX,OAAA;AACA,IAAAY,6BAAA,GAAAZ,OAAA;AAEA,IAAAa,uBAAA,GAAAb,OAAA;AACA,IAAAc,8BAAA,GAAAd,OAAA;AACA,IAAAe,gCAAA,GAAAf,OAAA;AAAmF,IAAAgB,WAAA,GAAAhB,OAAA;AAAA,SAAAO,uBAAAU,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,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAd,wBAAAc,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,C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N8B,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;EACD1B,KAAK,EAAE;IACL+B,KAAK,EAAER,qBAAM,CAACS,SAAS;IACvBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -18,16 +18,23 @@ class TranscriptionsDownloaderModel {
|
|
|
18
18
|
for (let attempt = 0; attempt < _constants.TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
19
19
|
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
20
20
|
if (response.status === 'completed') {
|
|
21
|
-
return
|
|
21
|
+
return {
|
|
22
|
+
text: response.text,
|
|
23
|
+
language: response.language
|
|
24
|
+
};
|
|
22
25
|
}
|
|
23
26
|
if (response.status === 'failed') {
|
|
24
|
-
return
|
|
27
|
+
return {
|
|
28
|
+
text: _constants.NO_AUDIO_BE_MESSAGE
|
|
29
|
+
};
|
|
25
30
|
}
|
|
26
31
|
if (attempt < _constants.TRANSCRIPT_MAX_RETRIES - 1) {
|
|
27
32
|
await new Promise(resolve => setTimeout(resolve, _constants.TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
return
|
|
35
|
+
return {
|
|
36
|
+
text: _constants.NO_AUDIO_BE_MESSAGE
|
|
37
|
+
};
|
|
31
38
|
}
|
|
32
39
|
loadAllTranscripts = (0, _effector.createEffect)(async () => {
|
|
33
40
|
const attempts = this.collection.getAll();
|
|
@@ -39,9 +46,13 @@ class TranscriptionsDownloaderModel {
|
|
|
39
46
|
transcriptLoading: true
|
|
40
47
|
});
|
|
41
48
|
try {
|
|
42
|
-
const
|
|
49
|
+
const {
|
|
50
|
+
text,
|
|
51
|
+
language
|
|
52
|
+
} = await this.fetchTranscriptWithRetry(item.audioFileId);
|
|
43
53
|
this.collection.update(item.attemptNumber, {
|
|
44
54
|
transcript: text,
|
|
55
|
+
transcriptLanguage: language,
|
|
45
56
|
transcriptLoading: false,
|
|
46
57
|
transcriptError: undefined
|
|
47
58
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_effector","require","_constants","TranscriptionsDownloaderModel","setTranscriptsLoaded","createEvent","reset","$transcriptsLoaded","restore","constructor","collection","api","fetchTranscriptWithRetry","audioFileId","attempt","TRANSCRIPT_MAX_RETRIES","response","getAudioFileTranscript","status","text","NO_AUDIO_BE_MESSAGE","Promise","resolve","setTimeout","TRANSCRIPT_RETRY_INTERVAL_MS","loadAllTranscripts","createEffect","attempts","getAll","transcriptPromises","map","item","hasTranscript","attemptNumber","update","transcriptLoading","transcript","transcriptError","undefined","error","Error","message","all","getTranscript","get","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;EAEhGG,WAAWA,CAACC,UAAyC,EAAEC,GAAmB,EAAE;IAC1E,IAAI,CAACD,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,GAAG,GAAGA,GAAG;EAChB;EAEA,MAAcC,wBAAwBA,
|
|
1
|
+
{"version":3,"names":["_effector","require","_constants","TranscriptionsDownloaderModel","setTranscriptsLoaded","createEvent","reset","$transcriptsLoaded","restore","constructor","collection","api","fetchTranscriptWithRetry","audioFileId","attempt","TRANSCRIPT_MAX_RETRIES","response","getAudioFileTranscript","status","text","language","NO_AUDIO_BE_MESSAGE","Promise","resolve","setTimeout","TRANSCRIPT_RETRY_INTERVAL_MS","loadAllTranscripts","createEffect","attempts","getAll","transcriptPromises","map","item","hasTranscript","attemptNumber","update","transcriptLoading","transcript","transcriptLanguage","transcriptError","undefined","error","Error","message","all","getTranscript","get","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;EAEhGG,WAAWA,CAACC,UAAyC,EAAEC,GAAmB,EAAE;IAC1E,IAAI,CAACD,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,GAAG,GAAGA,GAAG;EAChB;EAEA,MAAcC,wBAAwBA,CACpCC,WAAmB,EAC2B;IAC9C,KAAK,IAAIC,OAAO,GAAG,CAAC,EAAEA,OAAO,GAAGC,iCAAsB,EAAED,OAAO,EAAE,EAAE;MACjE,MAAME,QAAQ,GAAG,MAAM,IAAI,CAACL,GAAG,CAACM,sBAAsB,CAACJ,WAAW,CAAC;MAEnE,IAAIG,QAAQ,CAACE,MAAM,KAAK,WAAW,EAAE;QACnC,OAAO;UAAEC,IAAI,EAAEH,QAAQ,CAACG,IAAI;UAAEC,QAAQ,EAAEJ,QAAQ,CAACI;QAAS,CAAC;MAC7D;MAEA,IAAIJ,QAAQ,CAACE,MAAM,KAAK,QAAQ,EAAE;QAChC,OAAO;UAAEC,IAAI,EAAEE;QAAoB,CAAC;MACtC;MAEA,IAAI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AAoB,CAAC,IAAI,CAAC;EACjC,CAAC,CAAC;EAEKyC,aAAaA,CAACX,aAAqB,EAAsB;IAC9D,OAAO,IAAI,CAACxB,UAAU,CAACoC,GAAG,CAACZ,aAAa,CAAC,EAAEG,UAAU;EACvD;EAEOU,mBAAmBA,CAACb,aAAqB,EAAW;IACzD,OAAO,IAAI,CAACxB,UAAU,CAACoC,GAAG,CAACZ,aAAa,CAAC,EAAEE,iBAAiB,IAAI,KAAK;EACvE;AACF;AAACY,OAAA,CAAA7C,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
|
@@ -15,7 +15,6 @@ class VoicePlayerModel {
|
|
|
15
15
|
collection = new _VoiceTranscriptionsCollection.VoiceTranscriptionsCollection();
|
|
16
16
|
downloader = new _VoiceFileDownloaderModel.VoiceFileDownloaderModel();
|
|
17
17
|
dropdown = new _VoiceTranscriptionModel.VoiceTranscriptionModel();
|
|
18
|
-
translation = new _VoiceTranscriptionTranslationModel.VoiceTranscriptionTranslationModel();
|
|
19
18
|
playerModel = new _PlayerModel.PlayerModel();
|
|
20
19
|
currentPlayingAttempt = null;
|
|
21
20
|
shouldPreventPlayback = false;
|
|
@@ -38,10 +37,12 @@ class VoicePlayerModel {
|
|
|
38
37
|
this.currentPlayingAttempt = null;
|
|
39
38
|
this.setCurrentAttempt(null);
|
|
40
39
|
this.collection.clear();
|
|
40
|
+
this.translation.clearCache();
|
|
41
41
|
};
|
|
42
42
|
constructor(params) {
|
|
43
43
|
this.api = params.api;
|
|
44
44
|
this.loader = new _TranscriptionsDownloaderModel.TranscriptionsDownloaderModel(this.collection, params.api);
|
|
45
|
+
this.translation = new _VoiceTranscriptionTranslationModel.VoiceTranscriptionTranslationModel(this.collection, params.api);
|
|
45
46
|
this.downloader.setApi(params.api);
|
|
46
47
|
this.playerModel.playbackFinished.watch(() => {
|
|
47
48
|
this.currentPlayingAttempt = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_effector","require","_VoiceTranscriptionsCollection","_VoiceFileDownloaderModel","_VoiceTranscriptionModel","_VoiceTranscriptionTranslationModel","_PlayerModel","_TranscriptionsDownloaderModel","VoicePlayerModel","collection","VoiceTranscriptionsCollection","downloader","VoiceFileDownloaderModel","dropdown","VoiceTranscriptionModel","
|
|
1
|
+
{"version":3,"names":["_effector","require","_VoiceTranscriptionsCollection","_VoiceFileDownloaderModel","_VoiceTranscriptionModel","_VoiceTranscriptionTranslationModel","_PlayerModel","_TranscriptionsDownloaderModel","VoicePlayerModel","collection","VoiceTranscriptionsCollection","downloader","VoiceFileDownloaderModel","dropdown","VoiceTranscriptionModel","playerModel","PlayerModel","currentPlayingAttempt","shouldPreventPlayback","setCurrentAttempt","createEvent","reset","$currentAttempt","restore","$playerState","pauseAudio","pause","stopAudio","abortAllDownloads","stop","resetPlayer","releaseCollectionResources","clear","translation","clearCache","constructor","params","api","loader","TranscriptionsDownloaderModel","VoiceTranscriptionTranslationModel","setApi","playbackFinished","watch","audios","initializeCollectionFromAudios","setupAudioMode","initializeWithAudios","answerAudio","setTranscriptsLoaded","console","warn","forEach","audio","index","attemptNumber","audioFileId","add","_id","hasDrawing","drawing","getAll","item","controller","abortDownload","audioUri","startsWith","URL","revokeObjectURL","e","audioLoading","update","undefined","audioDownloadPromise","handlePlayAttempt","createEffect","get","hasAudio","playAudioFx","setPlayerState","PlayerState","LOADING","collectionItem","downloadPromise","download","abort","result","uri","audioError","IDLE","error","Error","name","message","player","remove","playing","resume","play","isAudioLoading","getAllAttempts","reinitializePlayer","reinitialize","cleanup","release","togglePlayPause","attach","source","mapParams","playerState","effect","PLAYING","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoicePlayer.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,8BAAA,GAAAD,OAAA;AACA,IAAAE,yBAAA,GAAAF,OAAA;AACA,IAAAG,wBAAA,GAAAH,OAAA;AACA,IAAAI,mCAAA,GAAAJ,OAAA;AAEA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AAC,CAAC;IACZ,IAAI,CAACiB,MAAM,CAACjB,KAAK,CAAC,CAAC;IACnB,IAAI,CAACR,QAAQ,CAACQ,KAAK,CAAC,CAAC;IACrB,IAAI,CAACY,WAAW,CAACZ,KAAK,CAAC,CAAC;IACxB,IAAI,CAACN,WAAW,CAACyF,OAAO,CAAC,CAAC;EAC5B;EAEOC,eAAe,GAAG,IAAAC,gBAAM,EAAC;IAC9BC,MAAM,EAAE,IAAI,CAAC5F,WAAW,CAACS,YAAY;IACrCoF,SAAS,EAAEA,CAACrD,aAAqB,EAAEsD,WAAW,MAAM;MAAEtD,aAAa;MAAEsD;IAAY,CAAC,CAAC;IACnFC,MAAM,EAAE,IAAAnC,sBAAY,EAAC,CAAC;MAAEpB,aAAa;MAAEsD;IAAmC,CAAC,KAAK;MAC9E,IAAI,IAAI,CAAC5F,qBAAqB,KAAKsC,aAAa,IAAIsD,WAAW,KAAK7B,wBAAW,CAAC+B,OAAO,EAAE;QACvF,IAAI,CAACtF,UAAU,CAAC,CAAC;MACnB,CAAC,MAAM;QACL,IAAI,CAACiD,iBAAiB,CAACnB,aAAa,CAAC;MACvC;IACF,CAAC;EACH,CAAC,CAAC;AACJ;AAACyD,OAAA,CAAAxG,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -8,8 +8,41 @@ var _effector = require("effector");
|
|
|
8
8
|
class VoiceTranscriptionTranslationModel {
|
|
9
9
|
toggle = (0, _effector.createEvent)();
|
|
10
10
|
setActive = (0, _effector.createEvent)();
|
|
11
|
+
clearCache = (0, _effector.createEvent)();
|
|
11
12
|
reset = (0, _effector.createEvent)();
|
|
12
13
|
$isActive = (0, _effector.restore)(this.setActive, false).on(this.toggle, state => !state).reset(this.reset);
|
|
14
|
+
translate = (0, _effector.createEffect)(async ({
|
|
15
|
+
attemptNumber,
|
|
16
|
+
targetLanguage
|
|
17
|
+
}) => {
|
|
18
|
+
const item = this.collection.get(attemptNumber);
|
|
19
|
+
if (!item?.transcript) return null;
|
|
20
|
+
const response = await this.api.translateText({
|
|
21
|
+
text: [item.transcript],
|
|
22
|
+
targetLanguage,
|
|
23
|
+
sourceLanguage: item.transcriptLanguage
|
|
24
|
+
});
|
|
25
|
+
const text = response.data.translations[0]?.translatedText;
|
|
26
|
+
if (!text) return null;
|
|
27
|
+
return {
|
|
28
|
+
attemptNumber,
|
|
29
|
+
text
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
$translations = (0, _effector.createStore)({}).on(this.translate.doneData, (state, result) => {
|
|
33
|
+
if (!result) return state;
|
|
34
|
+
return {
|
|
35
|
+
...state,
|
|
36
|
+
[result.attemptNumber]: result.text
|
|
37
|
+
};
|
|
38
|
+
}).reset(this.reset, this.clearCache);
|
|
39
|
+
constructor(collection, api) {
|
|
40
|
+
this.collection = collection;
|
|
41
|
+
this.api = api;
|
|
42
|
+
}
|
|
43
|
+
getTranslation(attemptNumber) {
|
|
44
|
+
return this.$translations.getState()[attemptNumber];
|
|
45
|
+
}
|
|
13
46
|
}
|
|
14
47
|
exports.VoiceTranscriptionTranslationModel = VoiceTranscriptionTranslationModel;
|
|
15
48
|
//# sourceMappingURL=VoiceTranscriptionTranslation.model.js.map
|
package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_effector","require","VoiceTranscriptionTranslationModel","toggle","createEvent","setActive","reset","$isActive","restore","on","state","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoiceTranscriptionTranslation.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_effector","require","VoiceTranscriptionTranslationModel","toggle","createEvent","setActive","clearCache","reset","$isActive","restore","on","state","translate","createEffect","attemptNumber","targetLanguage","item","collection","get","transcript","response","api","translateText","text","sourceLanguage","transcriptLanguage","data","translations","translatedText","$translations","createStore","doneData","result","constructor","getTranslation","getState","exports"],"sourceR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K,EAAEqB,MAAM,KAAK;IAC9C,IAAI,CAACA,MAAM,EAAE,OAAOrB,KAAK;IACzB,OAAO;MAAE,GAAGA,KAAK;MAAE,CAACqB,MAAM,CAAClB,aAAa,GAAGkB,MAAM,CAACT;IAAK,CAAC;EAC1D,CAAC,CAAC,CACDhB,KAAK,CAAC,IAAI,CAACA,KAAK,EAAE,IAAI,CAACD,UAAU,CAAC;EAErC2B,WAAWA,CAAChB,UAAyC,EAAEI,GAAmB,EAAE;IAC1E,IAAI,CAACJ,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACI,GAAG,GAAGA,GAAG;EAChB;EAEOa,cAAcA,CAACpB,aAAqB,EAAsB;IAC/D,OAAO,IAAI,CAACe,aAAa,CAACM,QAAQ,CAAC,CAAC,CAACrB,aAAa,CAAC;EACrD;AACF;AAACsB,OAAA,CAAAlC,kCAAA,GAAAA,kCAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RecordButtonVariant","exports","VoiceTranscriptionVariant"],"sourceRoot":"../../../../src","sources":["features/voice/types.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["RecordButtonVariant","exports","VoiceTranscriptionVariant"],"sourceRoot":"../../../../src","sources":["features/voice/types.ts"],"mappings":";;;;;;IAwFYA,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;AAAA,IAKnBE,yBAAyB,GAAAD,OAAA,CAAAC,yBAAA,0BAAzBA,yBAAyB;EAAzBA,yBAAyB;EAAzBA,yBAAyB;EAAA,OAAzBA,yBAAyB;AAAA","ignoreList":[]}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { Typography, COLORS } from '@magmamath/react-native-ui';
|
|
4
4
|
import { useUnit } from 'effector-react';
|
|
5
|
-
import React, { useCallback, useMemo } from 'react';
|
|
5
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
6
7
|
import { StyleSheet, View } from 'react-native';
|
|
7
8
|
import Animated from 'react-native-reanimated';
|
|
8
9
|
import { NO_AUDIO_BE_MESSAGE } from "../../constants.js";
|
|
@@ -24,7 +25,10 @@ export const VoiceTranscription = ({
|
|
|
24
25
|
variant = VoiceTranscriptionVariant.SMALL
|
|
25
26
|
}) => {
|
|
26
27
|
const t = useText();
|
|
27
|
-
const
|
|
28
|
+
const {
|
|
29
|
+
i18n
|
|
30
|
+
} = useTranslation();
|
|
31
|
+
const [playerState, isLoadingTranscripts, isTranslationActive, translations, isTranslating] = useUnit([model.$playerState, model.loader.loadAllTranscripts.pending, model.translation.$isActive, model.translation.$translations, model.translation.translate.pending]);
|
|
28
32
|
const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount);
|
|
29
33
|
const isLargeVariant = variant === VoiceTranscriptionVariant.LARGE;
|
|
30
34
|
const answersKey = useMemo(() => answers.map(a => `${a._id}:${a.audioFileId ?? ''}`).join(','), [answers]);
|
|
@@ -35,11 +39,22 @@ export const VoiceTranscription = ({
|
|
|
35
39
|
problemId,
|
|
36
40
|
activeAttempt
|
|
37
41
|
});
|
|
38
|
-
const
|
|
42
|
+
const hasActiveAudio = activeAttempt !== null && answers?.[activeAttempt - 1]?.audioFileId !== undefined;
|
|
39
43
|
const activeTranscript = activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null;
|
|
40
44
|
const hasTranscriptText = !!activeTranscript && activeTranscript !== NO_AUDIO_BE_MESSAGE;
|
|
41
|
-
const isActiveTranscriptLoading = isLoadingTranscripts &&
|
|
42
|
-
const
|
|
45
|
+
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript;
|
|
46
|
+
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined;
|
|
47
|
+
const showTranslation = isTranslationActive && hasTranscriptText;
|
|
48
|
+
const isTranslationLoading = showTranslation && !cachedTranslation && isTranslating;
|
|
49
|
+
const displayText = showTranslation ? cachedTranslation ?? activeTranscript : hasTranscriptText ? activeTranscript : t('voice.transcriptNotAvailable');
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
52
|
+
model.translation.translate({
|
|
53
|
+
attemptNumber: activeAttempt,
|
|
54
|
+
targetLanguage: i18n.language
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, [showTranslation, activeAttempt, cachedTranslation, isTranslating, i18n.language, model]);
|
|
43
58
|
const handlePlayPress = useCallback(() => {
|
|
44
59
|
if (activeAttempt) {
|
|
45
60
|
model.translation.setActive(false);
|
|
@@ -57,7 +72,7 @@ export const VoiceTranscription = ({
|
|
|
57
72
|
style: styles.title,
|
|
58
73
|
variant: "h7",
|
|
59
74
|
children: t('voice.transcriptions')
|
|
60
|
-
}),
|
|
75
|
+
}), hasActiveAudio && /*#__PURE__*/_jsx(VoiceTranscriptionHeaderActions, {
|
|
61
76
|
playerState: playerState,
|
|
62
77
|
isTranslationActive: isTranslationActive,
|
|
63
78
|
canTranslate: hasTranscriptText,
|
|
@@ -65,11 +80,11 @@ export const VoiceTranscription = ({
|
|
|
65
80
|
onTranslationPress: handleTranslationToggle
|
|
66
81
|
})]
|
|
67
82
|
}), isLargeVariant ? /*#__PURE__*/_jsx(VoiceTranscriptContent, {
|
|
68
|
-
text:
|
|
69
|
-
isLoading: isActiveTranscriptLoading
|
|
83
|
+
text: displayText,
|
|
84
|
+
isLoading: isActiveTranscriptLoading || isTranslationLoading
|
|
70
85
|
}) : /*#__PURE__*/_jsx(VoiceTranscriptionCollapsible, {
|
|
71
|
-
text:
|
|
72
|
-
isLoading: isActiveTranscriptLoading,
|
|
86
|
+
text: displayText,
|
|
87
|
+
isLoading: isActiveTranscriptLoading || isTranslationLoading,
|
|
73
88
|
dropdown: model.dropdown
|
|
74
89
|
})]
|
|
75
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Typography","COLORS","useUnit","React","useCallback","useMemo","StyleSheet","View","Animated","NO_AUDIO_BE_MESSAGE","getActiveAttempt","VoiceTranscriptionVariant","useText","useVoiceTranscriptionEffects","VoiceTranscriptContent","VoiceTranscriptionCollapsible","VoiceTranscriptionHeaderActions","jsx","_jsx","jsxs","_jsxs","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","SMALL","t","playerState","isLoadingTranscripts","isTranslationActive","$playerState","loader","loadAllTranscripts","pending","translation","$isActive","activeAttempt","isLargeVariant","LARGE","answersKey","map","a","_id","audioFileId","join","
|
|
1
|
+
{"version":3,"names":["Typography","COLORS","useUnit","React","useCallback","useEffect","useMemo","useTranslation","StyleSheet","View","Animated","NO_AUDIO_BE_MESSAGE","getActiveAttempt","VoiceTranscriptionVariant","useText","useVoiceTranscriptionEffects","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","cachedTranslation","showTranslation","isTranslationLoading","displayText","attemptNumber","targetLanguage","language","handlePlayPress","setActive","togglePlayPause","handleTranslationToggle","toggle","styles","container","largeContainer","children","header","title","canTranslate","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,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
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
15
15
|
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
16
16
|
if (response.status === 'completed') {
|
|
17
|
-
return
|
|
17
|
+
return {
|
|
18
|
+
text: response.text,
|
|
19
|
+
language: response.language
|
|
20
|
+
};
|
|
18
21
|
}
|
|
19
22
|
if (response.status === 'failed') {
|
|
20
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
text: NO_AUDIO_BE_MESSAGE
|
|
25
|
+
};
|
|
21
26
|
}
|
|
22
27
|
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
23
28
|
await new Promise(resolve => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
|
-
return
|
|
31
|
+
return {
|
|
32
|
+
text: NO_AUDIO_BE_MESSAGE
|
|
33
|
+
};
|
|
27
34
|
}
|
|
28
35
|
loadAllTranscripts = createEffect(async () => {
|
|
29
36
|
const attempts = this.collection.getAll();
|
|
@@ -35,9 +42,13 @@ export class TranscriptionsDownloaderModel {
|
|
|
35
42
|
transcriptLoading: true
|
|
36
43
|
});
|
|
37
44
|
try {
|
|
38
|
-
const
|
|
45
|
+
const {
|
|
46
|
+
text,
|
|
47
|
+
language
|
|
48
|
+
} = await this.fetchTranscriptWithRetry(item.audioFileId);
|
|
39
49
|
this.collection.update(item.attemptNumber, {
|
|
40
50
|
transcript: text,
|
|
51
|
+
transcriptLanguage: language,
|
|
41
52
|
transcriptLoading: false,
|
|
42
53
|
transcriptError: undefined
|
|
43
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEffect","createEvent","restore","NO_AUDIO_BE_MESSAGE","TRANSCRIPT_MAX_RETRIES","TRANSCRIPT_RETRY_INTERVAL_MS","TranscriptionsDownloaderModel","setTranscriptsLoaded","reset","$transcriptsLoaded","constructor","collection","api","fetchTranscriptWithRetry","audioFileId","attempt","response","getAudioFileTranscript","status","text","Promise","resolve","setTimeout","loadAllTranscripts","attempts","getAll","transcriptPromises","map","item","hasTranscript","attemptNumber","update","transcriptLoading","transcript","transcriptError","undefined","error","Error","message","all","getTranscript","get","isTranscriptLoading"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsDownloaderModel.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAU;AAG7D,SACEC,mBAAmB,EACnBC,sBAAsB,EACtBC,4BAA4B,QACvB,oBAAiB;AAExB,OAAO,MAAMC,6BAA6B,CAAC;EAIzBC,oBAAoB,GAAGN,WAAW,CAAU,CAAC;EAC7CO,KAAK,GAAGP,WAAW,CAAC,CAAC;EAErBQ,kBAAkB,GAAGP,OAAO,CAAC,IAAI,CAACK,oBAAoB,EAAE,KAAK,CAAC,CAACC,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EAEhGE,WAAWA,CAACC,UAAyC,EAAEC,GAAmB,EAAE;IAC1E,IAAI,CAACD,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,GAAG,GAAGA,GAAG;EAChB;EAEA,MAAcC,wBAAwBA,
|
|
1
|
+
{"version":3,"names":["createEffect","createEvent","restore","NO_AUDIO_BE_MESSAGE","TRANSCRIPT_MAX_RETRIES","TRANSCRIPT_RETRY_INTERVAL_MS","TranscriptionsDownloaderModel","setTranscriptsLoaded","reset","$transcriptsLoaded","constructor","collection","api","fetchTranscriptWithRetry","audioFileId","attempt","response","getAudioFileTranscript","status","text","language","Promise","resolve","setTimeout","loadAllTranscripts","attempts","getAll","transcriptPromises","map","item","hasTranscript","attemptNumber","update","transcriptLoading","transcript","transcriptLanguage","transcriptError","undefined","error","Error","message","all","getTranscript","get","isTranscriptLoading"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsDownloaderModel.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAU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[]}
|
|
@@ -11,7 +11,6 @@ export class VoicePlayerModel {
|
|
|
11
11
|
collection = new VoiceTranscriptionsCollection();
|
|
12
12
|
downloader = new VoiceFileDownloaderModel();
|
|
13
13
|
dropdown = new VoiceTranscriptionModel();
|
|
14
|
-
translation = new VoiceTranscriptionTranslationModel();
|
|
15
14
|
playerModel = new PlayerModel();
|
|
16
15
|
currentPlayingAttempt = null;
|
|
17
16
|
shouldPreventPlayback = false;
|
|
@@ -34,10 +33,12 @@ export class VoicePlayerModel {
|
|
|
34
33
|
this.currentPlayingAttempt = null;
|
|
35
34
|
this.setCurrentAttempt(null);
|
|
36
35
|
this.collection.clear();
|
|
36
|
+
this.translation.clearCache();
|
|
37
37
|
};
|
|
38
38
|
constructor(params) {
|
|
39
39
|
this.api = params.api;
|
|
40
40
|
this.loader = new TranscriptionsDownloaderModel(this.collection, params.api);
|
|
41
|
+
this.translation = new VoiceTranscriptionTranslationModel(this.collection, params.api);
|
|
41
42
|
this.downloader.setApi(params.api);
|
|
42
43
|
this.playerModel.playbackFinished.watch(() => {
|
|
43
44
|
this.currentPlayingAttempt = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["attach","createEffect","createEvent","restore","VoiceTranscriptionsCollection","VoiceFileDownloaderModel","VoiceTranscriptionModel","VoiceTranscriptionTranslationModel","PlayerModel","PlayerState","TranscriptionsDownloaderModel","VoicePlayerModel","collection","downloader","dropdown","
|
|
1
|
+
{"version":3,"names":["attach","createEffect","createEvent","restore","VoiceTranscriptionsCollection","VoiceFileDownloaderModel","VoiceTranscriptionModel","VoiceTranscriptionTranslationModel","PlayerModel","PlayerState","TranscriptionsDownloaderModel","VoicePlayerModel","collection","downloader","dropdown","playerModel","currentPlayingAttempt","shouldPreventPlayback","setCurrentAttempt","reset","$currentAttempt","$playerState","pauseAudio","pause","stopAudio","abortAllDownloads","stop","resetPlayer","releaseCollectionResources","clear","translation","clearCache","constructor","params","api","loader","setApi","playbackFinished","watch","audios","initializeCollectionFromAudios","setupAudioMode","initializeWithAudios","answerAudio","setTranscriptsLoaded","console","warn","forEach","audio","index","attemptNumber","audioFileId","add","_id","hasDrawing","drawing","getAll","item","controller","abortDownload","audioUri","startsWith","URL","revokeObjectURL","e","audioLoading","update","undefined","audioDownloadPromise","handlePlayAttempt","get","hasAudio","playAudioFx","setPlayerState","LOADING","collectionItem","downloadPromise","download","abort","result","uri","audioError","IDLE","error","Error","name","message","player","remove","playing","resume","play","isAudioLoading","getAllAttempts","reinitializePlayer","reinitialize","cleanup","release","togglePlayPause","source","mapParams","playerState","effect","PLAYING"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoicePlayer.model.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAU;AACrE,SAASC,6BAA6B,QAAQ,oCAAiC;AAC/E,SAASC,wBAAwB,QAAQ,gCAA6B;AACtE,SAASC,uBAAuB,QAAQ,+BAA4B;AACpE,SAASC,kCAAkC,QAAQ,0CAAuC;AAE1F,SAASC,WAAW,EAAEC,WAAW,QAAQ,mBAAgB;AACzD,SAASC,6BAA6B,QAAQ,oCAAiC;AAW/E,OAAO,MAAMC,gBAAgB,CAAC;EACZC,UAAU,GAAG,IAAIR,6BAA6B,CAAC,CAAC;EAChDS,UAAU,GAAG,IAAIR,wBAAwB,CAAC,CAAC;EAC3CS,QAAQ,GAAG,IAAIR,uBAAuB,CAAC,CAAC;EAExCS,WAAW,GAAG,IAAIP,WAAW,CAAC,CAAC;EAGvCQ,qBAAqB,GAAkB,IAAI;EAC3CC,qBAAqB,GAAG,KAAK;EAErBC,iBAAiB,GAAGhB,WAAW,CAAgB,CAAC;EAChDiB,KAAK,GAAGjB,WAAW,CAAC,CAAC;EAErBkB,eAAe,GAAGjB,OAAO,CAAC,IAAI,CAACe,iBAAiB,EAAE,IAAI,CAAC,CAACC,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EACzEE,YAAY,GAAG,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AI,CAACjF,UAAU,CAAC,CAAC;MACnB,CAAC,MAAM;QACL,IAAI,CAAC+C,iBAAiB,CAACnB,aAAa,CAAC;MACvC;IACF,CAAC;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { createEvent, restore } from 'effector';
|
|
3
|
+
import { createEffect, createEvent, createStore, restore } from 'effector';
|
|
4
4
|
export class VoiceTranscriptionTranslationModel {
|
|
5
5
|
toggle = createEvent();
|
|
6
6
|
setActive = createEvent();
|
|
7
|
+
clearCache = createEvent();
|
|
7
8
|
reset = createEvent();
|
|
8
9
|
$isActive = restore(this.setActive, false).on(this.toggle, state => !state).reset(this.reset);
|
|
10
|
+
translate = createEffect(async ({
|
|
11
|
+
attemptNumber,
|
|
12
|
+
targetLanguage
|
|
13
|
+
}) => {
|
|
14
|
+
const item = this.collection.get(attemptNumber);
|
|
15
|
+
if (!item?.transcript) return null;
|
|
16
|
+
const response = await this.api.translateText({
|
|
17
|
+
text: [item.transcript],
|
|
18
|
+
targetLanguage,
|
|
19
|
+
sourceLanguage: item.transcriptLanguage
|
|
20
|
+
});
|
|
21
|
+
const text = response.data.translations[0]?.translatedText;
|
|
22
|
+
if (!text) return null;
|
|
23
|
+
return {
|
|
24
|
+
attemptNumber,
|
|
25
|
+
text
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
$translations = createStore({}).on(this.translate.doneData, (state, result) => {
|
|
29
|
+
if (!result) return state;
|
|
30
|
+
return {
|
|
31
|
+
...state,
|
|
32
|
+
[result.attemptNumber]: result.text
|
|
33
|
+
};
|
|
34
|
+
}).reset(this.reset, this.clearCache);
|
|
35
|
+
constructor(collection, api) {
|
|
36
|
+
this.collection = collection;
|
|
37
|
+
this.api = api;
|
|
38
|
+
}
|
|
39
|
+
getTranslation(attemptNumber) {
|
|
40
|
+
return this.$translations.getState()[attemptNumber];
|
|
41
|
+
}
|
|
9
42
|
}
|
|
10
43
|
//# sourceMappingURL=VoiceTranscriptionTranslation.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEvent","restore","VoiceTranscriptionTranslationModel","toggle","setActive","reset","$isActive","on","state"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoiceTranscriptionTranslation.model.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,UAAU;
|
|
1
|
+
{"version":3,"names":["createEffect","createEvent","createStore","restore","VoiceTranscriptionTranslationModel","toggle","setActive","clearCache","reset","$isActive","on","state","translate","attemptNumber","targetLanguage","item","collection","get","transcript","response","api","translateText","text","sourceLanguage","transcriptLanguage","data","translations","translatedText","$translations","doneData","result","constructor","getTranslation","getState"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoiceTranscriptionTranslation.model.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAU;AAc1E,OAAO,MAAMC,kCAAkC,CAAC;EAI9BC,MAAM,GAAGJ,WAAW,CAAC,CAAC;EACtBK,SAAS,GAAGL,WAAW,CAAU,CAAC;EAClCM,UAAU,GAAGN,WAAW,CAAC,CAAC;EAC1BO,KAAK,GAAGP,WAAW,CAAC,CAAC;EAErBQ,SAAS,GAAGN,OAAO,CAAC,IAAI,CAACG,SAAS,EAAE,KAAK,CAAC,CACvDI,EAAE,CAAC,IAAI,CAACL,MAAM,EAAGM,KAAK,IAAK,CAACA,KAAK,CAAC,CAClCH,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EAEJI,SAAS,GAAGZ,YAAY,CACtC,OAAO;IAAEa,aAAa;IAAEC;EAAe,CAAC,KAAK;IAC3C,MAAMC,IAAI,GAAG,IAAI,CAACC,UAAU,CAACC,GAAG,CAACJ,aAAa,CAAC;IAC/C,IAAI,CAACE,IAAI,EAAEG,UAAU,EAAE,OAAO,IAAI;IAElC,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACC,GAAG,CAACC,aAAa,CAAC;MAC5CC,IAAI,EAAE,CAACP,IAAI,CAACG,UAAU,CAAC;MACvBJ,cAAc;MACdS,cAAc,EAAER,IAAI,CAACS;IACvB,CAAC,CAAC;IAEF,MAAMF,IAAI,GAAGH,QAAQ,CAACM,IAAI,CAACC,YAAY,CAAC,CAAC,CAAC,EAAEC,cAAc;IAC1D,IAAI,CAACL,IAAI,EAAE,OAAO,IAAI;IAEtB,OAAO;MAAET,aAAa;MAAES;IAAK,CAAC;EAChC,CACF,CAAC;EAEeM,aAAa,GAAG1B,WAAW,CAAyB,CAAC,CAAC,CAAC,CACpEQ,EAAE,CAAC,IAAI,CAACE,SAAS,CAACiB,QAAQ,EAAE,CAAClB,KAAK,EAAEmB,MAAM,KAAK;IAC9C,IAAI,CAACA,MAAM,EAAE,OAAOnB,KAAK;IACzB,OAAO;MAAE,GAAGA,KAAK;MAAE,CAACmB,MAAM,CAACjB,aAAa,GAAGiB,MAAM,CAACR;IAAK,CAAC;EAC1D,CAAC,CAAC,CACDd,KAAK,CAAC,IAAI,CAACA,KAAK,EAAE,IAAI,CAACD,UAAU,CAAC;EAErCwB,WAAWA,CAACf,UAAyC,EAAEI,GAAmB,EAAE;IAC1E,IAAI,CAACJ,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACI,GAAG,GAAGA,GAAG;EAChB;EAEOY,cAAcA,CAACnB,aAAqB,EAAsB;IAC/D,OAAO,IAAI,CAACe,aAAa,CAACK,QAAQ,CAAC,CAAC,CAACpB,aAAa,CAAC;EACrD;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RecordButtonVariant","VoiceTranscriptionVariant"],"sourceRoot":"../../../../src","sources":["features/voice/types.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["RecordButtonVariant","VoiceTranscriptionVariant"],"sourceRoot":"../../../../src","sources":["features/voice/types.ts"],"mappings":";;AAwFA,WAAYA,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;AAK/B,WAAYC,yBAAyB,0BAAzBA,yBAAyB;EAAzBA,yBAAyB;EAAzBA,yBAAyB;EAAA,OAAzBA,yBAAyB;AAAA","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,
|
|
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;AAGpE,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,sBAgGzB,CAAA"}
|
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;gBAEpF,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;YAK5D,wBAAwB;
|
|
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;gBAEpF,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;YAK5D,wBAAwB;IAqBtC,SAAgB,kBAAkB,+CA6BhC;IAEK,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIxD,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;CAG3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoicePlayer.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoicePlayer.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAA;AAC1F,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAE/E,KAAK,oCAAoC,GAAG;IAC1C,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;CACvB,CAAA;AAMD,qBAAa,gBAAgB;IAC3B,SAAgB,UAAU,gCAAsC;IAChE,SAAgB,UAAU,2BAAiC;IAC3D,SAAgB,QAAQ,0BAAgC;IACxD,SAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"VoicePlayer.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoicePlayer.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAA;AAC1F,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAE/E,KAAK,oCAAoC,GAAG;IAC1C,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;CACvB,CAAA;AAMD,qBAAa,gBAAgB;IAC3B,SAAgB,UAAU,gCAAsC;IAChE,SAAgB,UAAU,2BAAiC;IAC3D,SAAgB,QAAQ,0BAAgC;IACxD,SAAgB,WAAW,EAAE,kCAAkC,CAAA;IAC/D,SAAgB,WAAW,cAAoB;IAC/C,SAAgB,MAAM,EAAE,6BAA6B,CAAA;IACrD,SAAgB,GAAG,EAAE,cAAc,CAAA;IACnC,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,qBAAqB,CAAQ;IAErC,SAAgB,iBAAiB,kDAA+B;IAChE,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,eAAe,kDAA0D;IACzF,SAAgB,YAAY,gDAAgC;IAE5D,SAAgB,UAAU,+CAAyB;IAEnD,SAAgB,SAAS,aAMxB;IAED,SAAgB,WAAW,aAQ1B;gBAEW,MAAM,EAAE,oCAAoC;IAkBjD,oBAAoB,CAAC,WAAW,EAAE,WAAW,EAAE;IAMtD,OAAO,CAAC,8BAA8B;IAoBtC,OAAO,CAAC,0BAA0B;IAalC,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CA6DhC;IAEF,OAAO,CAAC,WAAW,CAmCjB;IAEK,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAI9C,cAAc,IAAI,sBAAsB,EAAE;IAI1C,kBAAkB;IAIlB,OAAO;IAWP,eAAe,iDAUpB;CACH"}
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
import { VoiceTranscriptionsCollection } from './VoiceTranscriptionsCollection';
|
|
2
|
+
import { VoicePlayerApi } from '../../types';
|
|
3
|
+
type TranslateParams = {
|
|
4
|
+
attemptNumber: number;
|
|
5
|
+
targetLanguage: string;
|
|
6
|
+
};
|
|
7
|
+
type TranslateResult = {
|
|
8
|
+
attemptNumber: number;
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
1
11
|
export declare class VoiceTranscriptionTranslationModel {
|
|
12
|
+
private readonly collection;
|
|
13
|
+
private readonly api;
|
|
2
14
|
readonly toggle: import("effector").EventCallable<void>;
|
|
3
15
|
readonly setActive: import("effector").EventCallable<boolean>;
|
|
16
|
+
readonly clearCache: import("effector").EventCallable<void>;
|
|
4
17
|
readonly reset: import("effector").EventCallable<void>;
|
|
5
18
|
readonly $isActive: import("effector").StoreWritable<boolean>;
|
|
19
|
+
readonly translate: import("effector").Effect<TranslateParams, TranslateResult | null, Error>;
|
|
20
|
+
readonly $translations: import("effector").StoreWritable<Record<number, string>>;
|
|
21
|
+
constructor(collection: VoiceTranscriptionsCollection, api: VoicePlayerApi);
|
|
22
|
+
getTranslation(attemptNumber: number): string | undefined;
|
|
6
23
|
}
|
|
24
|
+
export {};
|
|
7
25
|
//# sourceMappingURL=VoiceTranscriptionTranslation.model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTranscriptionTranslation.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VoiceTranscriptionTranslation.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,qBAAa,kCAAkC;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IAEpC,SAAgB,MAAM,yCAAgB;IACtC,SAAgB,SAAS,4CAAyB;IAClD,SAAgB,UAAU,yCAAgB;IAC1C,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,SAAS,4CAEL;IAEpB,SAAgB,SAAS,4EAgBxB;IAED,SAAgB,aAAa,2DAKQ;gBAEzB,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;IAKnE,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGjE"}
|
|
@@ -54,12 +54,14 @@ export type VoicePlayerApi = {
|
|
|
54
54
|
downloadAudioFile: (audioFileId: string, options?: {
|
|
55
55
|
signal?: AbortSignal;
|
|
56
56
|
}) => Promise<AxiosResponse<Blob>>;
|
|
57
|
+
translateText: (payload: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>;
|
|
57
58
|
};
|
|
58
59
|
export type VoiceTranscriptionItem = {
|
|
59
60
|
attemptNumber: number;
|
|
60
61
|
audioFileId: string;
|
|
61
62
|
_id: string;
|
|
62
63
|
transcript?: string;
|
|
64
|
+
transcriptLanguage?: string;
|
|
63
65
|
transcriptLoading?: boolean;
|
|
64
66
|
transcriptError?: string;
|
|
65
67
|
audioUri?: string;
|
|
@@ -77,5 +79,19 @@ export declare enum VoiceTranscriptionVariant {
|
|
|
77
79
|
SMALL = "small",
|
|
78
80
|
LARGE = "large"
|
|
79
81
|
}
|
|
82
|
+
export type GoogleTranslatePayload = {
|
|
83
|
+
text: string[];
|
|
84
|
+
targetLanguage: string;
|
|
85
|
+
sourceLanguage?: string;
|
|
86
|
+
};
|
|
87
|
+
type Translation = {
|
|
88
|
+
translatedText: string;
|
|
89
|
+
detectedSourceLanguage: string;
|
|
90
|
+
};
|
|
91
|
+
export type GoogleTranslateResponse = {
|
|
92
|
+
data: {
|
|
93
|
+
translations: Translation[];
|
|
94
|
+
};
|
|
95
|
+
};
|
|
80
96
|
export {};
|
|
81
97
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1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AAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACnC,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,oBAAY,mBAAmB;IAC7B,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED,oBAAY,yBAAyB;IACnC,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AACD,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,sBAAsB,EAAE,MAAM,CAAA;CAC/B,CAAA;AACD,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE;QACJ,YAAY,EAAE,WAAW,EAAE,CAAA;KAC5B,CAAA;CACF,CAAA"}
|
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,
|
|
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;AAGpE,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,sBAgGzB,CAAA"}
|
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;gBAEpF,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;YAK5D,wBAAwB;
|
|
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;gBAEpF,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;YAK5D,wBAAwB;IAqBtC,SAAgB,kBAAkB,+CA6BhC;IAEK,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIxD,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;CAG3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoicePlayer.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoicePlayer.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAA;AAC1F,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAE/E,KAAK,oCAAoC,GAAG;IAC1C,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;CACvB,CAAA;AAMD,qBAAa,gBAAgB;IAC3B,SAAgB,UAAU,gCAAsC;IAChE,SAAgB,UAAU,2BAAiC;IAC3D,SAAgB,QAAQ,0BAAgC;IACxD,SAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"VoicePlayer.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoicePlayer.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EA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AW,CAmCjB;IAEK,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAI9C,cAAc,IAAI,sBAAsB,EAAE;IAI1C,kBAAkB;IAIlB,OAAO;IAWP,eAAe,iDAUpB;CACH"}
|
package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
import { VoiceTranscriptionsCollection } from './VoiceTranscriptionsCollection';
|
|
2
|
+
import { VoicePlayerApi } from '../../types';
|
|
3
|
+
type TranslateParams = {
|
|
4
|
+
attemptNumber: number;
|
|
5
|
+
targetLanguage: string;
|
|
6
|
+
};
|
|
7
|
+
type TranslateResult = {
|
|
8
|
+
attemptNumber: number;
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
1
11
|
export declare class VoiceTranscriptionTranslationModel {
|
|
12
|
+
private readonly collection;
|
|
13
|
+
private readonly api;
|
|
2
14
|
readonly toggle: import("effector").EventCallable<void>;
|
|
3
15
|
readonly setActive: import("effector").EventCallable<boolean>;
|
|
16
|
+
readonly clearCache: import("effector").EventCallable<void>;
|
|
4
17
|
readonly reset: import("effector").EventCallable<void>;
|
|
5
18
|
readonly $isActive: import("effector").StoreWritable<boolean>;
|
|
19
|
+
readonly translate: import("effector").Effect<TranslateParams, TranslateResult | null, Error>;
|
|
20
|
+
readonly $translations: import("effector").StoreWritable<Record<number, string>>;
|
|
21
|
+
constructor(collection: VoiceTranscriptionsCollection, api: VoicePlayerApi);
|
|
22
|
+
getTranslation(attemptNumber: number): string | undefined;
|
|
6
23
|
}
|
|
24
|
+
export {};
|
|
7
25
|
//# sourceMappingURL=VoiceTranscriptionTranslation.model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTranscriptionTranslation.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VoiceTranscriptionTranslation.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,qBAAa,kCAAkC;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IAEpC,SAAgB,MAAM,yCAAgB;IACtC,SAAgB,SAAS,4CAAyB;IAClD,SAAgB,UAAU,yCAAgB;IAC1C,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,SAAS,4CAEL;IAEpB,SAAgB,SAAS,4EAgBxB;IAED,SAAgB,aAAa,2DAKQ;gBAEzB,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;IAKnE,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGjE"}
|
|
@@ -54,12 +54,14 @@ export type VoicePlayerApi = {
|
|
|
54
54
|
downloadAudioFile: (audioFileId: string, options?: {
|
|
55
55
|
signal?: AbortSignal;
|
|
56
56
|
}) => Promise<AxiosResponse<Blob>>;
|
|
57
|
+
translateText: (payload: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>;
|
|
57
58
|
};
|
|
58
59
|
export type VoiceTranscriptionItem = {
|
|
59
60
|
attemptNumber: number;
|
|
60
61
|
audioFileId: string;
|
|
61
62
|
_id: string;
|
|
62
63
|
transcript?: string;
|
|
64
|
+
transcriptLanguage?: string;
|
|
63
65
|
transcriptLoading?: boolean;
|
|
64
66
|
transcriptError?: string;
|
|
65
67
|
audioUri?: string;
|
|
@@ -77,5 +79,19 @@ export declare enum VoiceTranscriptionVariant {
|
|
|
77
79
|
SMALL = "small",
|
|
78
80
|
LARGE = "large"
|
|
79
81
|
}
|
|
82
|
+
export type GoogleTranslatePayload = {
|
|
83
|
+
text: string[];
|
|
84
|
+
targetLanguage: string;
|
|
85
|
+
sourceLanguage?: string;
|
|
86
|
+
};
|
|
87
|
+
type Translation = {
|
|
88
|
+
translatedText: string;
|
|
89
|
+
detectedSourceLanguage: string;
|
|
90
|
+
};
|
|
91
|
+
export type GoogleTranslateResponse = {
|
|
92
|
+
data: {
|
|
93
|
+
translations: Translation[];
|
|
94
|
+
};
|
|
95
|
+
};
|
|
80
96
|
export {};
|
|
81
97
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/voice/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,MAAM,MAAM,4BAA4B,GAAG;IACzC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC;IAC/C,iBAAiB,EAAE,QAAQ,CAAA;CAC5B,CAAC,CAAA;AAEF,KAAK,mBAAmB,GAAG;IACzB,EAAE,E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 +1,7 @@
|
|
|
1
1
|
import { Typography, COLORS } from '@magmamath/react-native-ui'
|
|
2
2
|
import { useUnit } from 'effector-react'
|
|
3
|
-
import React, { useCallback, useMemo } from 'react'
|
|
3
|
+
import React, { useCallback, useEffect, useMemo } from 'react'
|
|
4
|
+
import { useTranslation } from 'react-i18next'
|
|
4
5
|
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'
|
|
5
6
|
import Animated from 'react-native-reanimated'
|
|
6
7
|
import { NO_AUDIO_BE_MESSAGE } from '../../constants'
|
|
@@ -33,11 +34,20 @@ export const VoiceTranscription = ({
|
|
|
33
34
|
variant = VoiceTranscriptionVariant.SMALL,
|
|
34
35
|
}: VoiceTranscriptionProps) => {
|
|
35
36
|
const t = useText()
|
|
37
|
+
const { i18n } = useTranslation()
|
|
36
38
|
|
|
37
|
-
const [
|
|
39
|
+
const [
|
|
40
|
+
playerState,
|
|
41
|
+
isLoadingTranscripts,
|
|
42
|
+
isTranslationActive,
|
|
43
|
+
translations,
|
|
44
|
+
isTranslating,
|
|
45
|
+
] = useUnit([
|
|
38
46
|
model.$playerState,
|
|
39
47
|
model.loader.loadAllTranscripts.pending,
|
|
40
48
|
model.translation.$isActive,
|
|
49
|
+
model.translation.$translations,
|
|
50
|
+
model.translation.translate.pending,
|
|
41
51
|
])
|
|
42
52
|
|
|
43
53
|
const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount)
|
|
@@ -50,15 +60,31 @@ export const VoiceTranscription = ({
|
|
|
50
60
|
|
|
51
61
|
useVoiceTranscriptionEffects({ model, answers, answersKey, problemId, activeAttempt })
|
|
52
62
|
|
|
53
|
-
const
|
|
63
|
+
const hasActiveAudio =
|
|
54
64
|
activeAttempt !== null && answers?.[activeAttempt - 1]?.audioFileId !== undefined
|
|
55
65
|
|
|
56
66
|
const activeTranscript = activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null
|
|
57
67
|
const hasTranscriptText = !!activeTranscript && activeTranscript !== NO_AUDIO_BE_MESSAGE
|
|
58
|
-
const isActiveTranscriptLoading = isLoadingTranscripts &&
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript
|
|
69
|
+
|
|
70
|
+
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined
|
|
71
|
+
const showTranslation = isTranslationActive && hasTranscriptText
|
|
72
|
+
const isTranslationLoading = showTranslation && !cachedTranslation && isTranslating
|
|
73
|
+
|
|
74
|
+
const displayText = showTranslation
|
|
75
|
+
? cachedTranslation ?? activeTranscript!
|
|
76
|
+
: hasTranscriptText
|
|
77
|
+
? activeTranscript!
|
|
78
|
+
: t('voice.transcriptNotAvailable')
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
82
|
+
model.translation.translate({
|
|
83
|
+
attemptNumber: activeAttempt,
|
|
84
|
+
targetLanguage: i18n.language,
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}, [showTranslation, activeAttempt, cachedTranslation, isTranslating, i18n.language, model])
|
|
62
88
|
|
|
63
89
|
const handlePlayPress = useCallback(() => {
|
|
64
90
|
if (activeAttempt) {
|
|
@@ -77,7 +103,7 @@ export const VoiceTranscription = ({
|
|
|
77
103
|
<Typography style={styles.title} variant="h7">
|
|
78
104
|
{t('voice.transcriptions')}
|
|
79
105
|
</Typography>
|
|
80
|
-
{
|
|
106
|
+
{hasActiveAudio && (
|
|
81
107
|
<VoiceTranscriptionHeaderActions
|
|
82
108
|
playerState={playerState}
|
|
83
109
|
isTranslationActive={isTranslationActive}
|
|
@@ -89,11 +115,14 @@ export const VoiceTranscription = ({
|
|
|
89
115
|
</View>
|
|
90
116
|
|
|
91
117
|
{isLargeVariant ? (
|
|
92
|
-
<VoiceTranscriptContent
|
|
118
|
+
<VoiceTranscriptContent
|
|
119
|
+
text={displayText}
|
|
120
|
+
isLoading={isActiveTranscriptLoading || isTranslationLoading}
|
|
121
|
+
/>
|
|
93
122
|
) : (
|
|
94
123
|
<VoiceTranscriptionCollapsible
|
|
95
|
-
text={
|
|
96
|
-
isLoading={isActiveTranscriptLoading}
|
|
124
|
+
text={displayText}
|
|
125
|
+
isLoading={isActiveTranscriptLoading || isTranslationLoading}
|
|
97
126
|
dropdown={model.dropdown}
|
|
98
127
|
/>
|
|
99
128
|
)}
|
|
@@ -21,23 +21,25 @@ export class TranscriptionsDownloaderModel {
|
|
|
21
21
|
this.api = api
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
private async fetchTranscriptWithRetry(
|
|
24
|
+
private async fetchTranscriptWithRetry(
|
|
25
|
+
audioFileId: string,
|
|
26
|
+
): Promise<{ text: string; language?: string }> {
|
|
25
27
|
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
26
28
|
const response = await this.api.getAudioFileTranscript(audioFileId)
|
|
27
29
|
|
|
28
30
|
if (response.status === 'completed') {
|
|
29
|
-
return response.text
|
|
31
|
+
return { text: response.text, language: response.language }
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
if (response.status === 'failed') {
|
|
33
|
-
return NO_AUDIO_BE_MESSAGE
|
|
35
|
+
return { text: NO_AUDIO_BE_MESSAGE }
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
37
39
|
await new Promise((resolve) => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS))
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
|
-
return NO_AUDIO_BE_MESSAGE
|
|
42
|
+
return { text: NO_AUDIO_BE_MESSAGE }
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
public readonly loadAllTranscripts = createEffect(async () => {
|
|
@@ -51,10 +53,11 @@ export class TranscriptionsDownloaderModel {
|
|
|
51
53
|
this.collection.update(item.attemptNumber, { transcriptLoading: true })
|
|
52
54
|
|
|
53
55
|
try {
|
|
54
|
-
const text = await this.fetchTranscriptWithRetry(item.audioFileId)
|
|
56
|
+
const { text, language } = await this.fetchTranscriptWithRetry(item.audioFileId)
|
|
55
57
|
|
|
56
58
|
this.collection.update(item.attemptNumber, {
|
|
57
59
|
transcript: text,
|
|
60
|
+
transcriptLanguage: language,
|
|
58
61
|
transcriptLoading: false,
|
|
59
62
|
transcriptError: undefined,
|
|
60
63
|
})
|
|
@@ -20,7 +20,7 @@ export class VoicePlayerModel {
|
|
|
20
20
|
public readonly collection = new VoiceTranscriptionsCollection()
|
|
21
21
|
public readonly downloader = new VoiceFileDownloaderModel()
|
|
22
22
|
public readonly dropdown = new VoiceTranscriptionModel()
|
|
23
|
-
public readonly translation
|
|
23
|
+
public readonly translation: VoiceTranscriptionTranslationModel
|
|
24
24
|
public readonly playerModel = new PlayerModel()
|
|
25
25
|
public readonly loader: TranscriptionsDownloaderModel
|
|
26
26
|
public readonly api: VoicePlayerApi
|
|
@@ -50,11 +50,13 @@ export class VoicePlayerModel {
|
|
|
50
50
|
this.currentPlayingAttempt = null
|
|
51
51
|
this.setCurrentAttempt(null)
|
|
52
52
|
this.collection.clear()
|
|
53
|
+
this.translation.clearCache()
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
constructor(params: VoiceTranscriptionsPlayerModelParams) {
|
|
56
57
|
this.api = params.api
|
|
57
58
|
this.loader = new TranscriptionsDownloaderModel(this.collection, params.api)
|
|
59
|
+
this.translation = new VoiceTranscriptionTranslationModel(this.collection, params.api)
|
|
58
60
|
this.downloader.setApi(params.api)
|
|
59
61
|
|
|
60
62
|
this.playerModel.playbackFinished.watch(() => {
|
|
@@ -1,11 +1,61 @@
|
|
|
1
|
-
import { createEvent, restore } from 'effector'
|
|
1
|
+
import { createEffect, createEvent, createStore, restore } from 'effector'
|
|
2
|
+
import { VoiceTranscriptionsCollection } from './VoiceTranscriptionsCollection'
|
|
3
|
+
import { VoicePlayerApi } from '../../types'
|
|
4
|
+
|
|
5
|
+
type TranslateParams = {
|
|
6
|
+
attemptNumber: number
|
|
7
|
+
targetLanguage: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type TranslateResult = {
|
|
11
|
+
attemptNumber: number
|
|
12
|
+
text: string
|
|
13
|
+
}
|
|
2
14
|
|
|
3
15
|
export class VoiceTranscriptionTranslationModel {
|
|
16
|
+
private readonly collection: VoiceTranscriptionsCollection
|
|
17
|
+
private readonly api: VoicePlayerApi
|
|
18
|
+
|
|
4
19
|
public readonly toggle = createEvent()
|
|
5
20
|
public readonly setActive = createEvent<boolean>()
|
|
21
|
+
public readonly clearCache = createEvent()
|
|
6
22
|
public readonly reset = createEvent()
|
|
7
23
|
|
|
8
24
|
public readonly $isActive = restore(this.setActive, false)
|
|
9
25
|
.on(this.toggle, (state) => !state)
|
|
10
26
|
.reset(this.reset)
|
|
27
|
+
|
|
28
|
+
public readonly translate = createEffect<TranslateParams, TranslateResult | null>(
|
|
29
|
+
async ({ attemptNumber, targetLanguage }) => {
|
|
30
|
+
const item = this.collection.get(attemptNumber)
|
|
31
|
+
if (!item?.transcript) return null
|
|
32
|
+
|
|
33
|
+
const response = await this.api.translateText({
|
|
34
|
+
text: [item.transcript],
|
|
35
|
+
targetLanguage,
|
|
36
|
+
sourceLanguage: item.transcriptLanguage,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const text = response.data.translations[0]?.translatedText
|
|
40
|
+
if (!text) return null
|
|
41
|
+
|
|
42
|
+
return { attemptNumber, text }
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
public readonly $translations = createStore<Record<number, string>>({})
|
|
47
|
+
.on(this.translate.doneData, (state, result) => {
|
|
48
|
+
if (!result) return state
|
|
49
|
+
return { ...state, [result.attemptNumber]: result.text }
|
|
50
|
+
})
|
|
51
|
+
.reset(this.reset, this.clearCache)
|
|
52
|
+
|
|
53
|
+
constructor(collection: VoiceTranscriptionsCollection, api: VoicePlayerApi) {
|
|
54
|
+
this.collection = collection
|
|
55
|
+
this.api = api
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public getTranslation(attemptNumber: number): string | undefined {
|
|
59
|
+
return this.$translations.getState()[attemptNumber]
|
|
60
|
+
}
|
|
11
61
|
}
|
|
@@ -67,6 +67,7 @@ export type VoicePlayerApi = {
|
|
|
67
67
|
audioFileId: string,
|
|
68
68
|
options?: { signal?: AbortSignal },
|
|
69
69
|
) => Promise<AxiosResponse<Blob>>
|
|
70
|
+
translateText: (payload: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export type VoiceTranscriptionItem = {
|
|
@@ -74,6 +75,7 @@ export type VoiceTranscriptionItem = {
|
|
|
74
75
|
audioFileId: string
|
|
75
76
|
_id: string
|
|
76
77
|
transcript?: string
|
|
78
|
+
transcriptLanguage?: string
|
|
77
79
|
transcriptLoading?: boolean
|
|
78
80
|
transcriptError?: string
|
|
79
81
|
audioUri?: string
|
|
@@ -93,3 +95,18 @@ export enum VoiceTranscriptionVariant {
|
|
|
93
95
|
SMALL = 'small',
|
|
94
96
|
LARGE = 'large',
|
|
95
97
|
}
|
|
98
|
+
|
|
99
|
+
export type GoogleTranslatePayload = {
|
|
100
|
+
text: string[]
|
|
101
|
+
targetLanguage: string
|
|
102
|
+
sourceLanguage?: string
|
|
103
|
+
}
|
|
104
|
+
type Translation = {
|
|
105
|
+
translatedText: string
|
|
106
|
+
detectedSourceLanguage: string
|
|
107
|
+
}
|
|
108
|
+
export type GoogleTranslateResponse = {
|
|
109
|
+
data: {
|
|
110
|
+
translations: Translation[]
|
|
111
|
+
}
|
|
112
|
+
}
|