@magmamath/students-features 1.3.23-rc.2 → 1.3.23-rc.21
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/translation/constants.js +11 -0
- package/dist/commonjs/features/translation/constants.js.map +1 -0
- package/dist/commonjs/features/translation/helpers.js +60 -0
- package/dist/commonjs/features/translation/helpers.js.map +1 -0
- package/dist/commonjs/features/translation/index.js +105 -0
- package/dist/commonjs/features/translation/index.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationModel.js +122 -0
- package/dist/commonjs/features/translation/model/TranslationModel.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationPreprocessor.js +142 -0
- package/dist/commonjs/features/translation/model/TranslationPreprocessor.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationService.js +112 -0
- package/dist/commonjs/features/translation/model/TranslationService.js.map +1 -0
- package/dist/commonjs/features/translation/preserve/wordsToPreserve.js +314 -0
- package/dist/commonjs/features/translation/preserve/wordsToPreserve.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js +50 -0
- package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google/supportedLanguages.js +230 -0
- package/dist/commonjs/features/translation/providers/google/supportedLanguages.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google.types.js +2 -0
- package/dist/commonjs/features/translation/providers/google.types.js.map +1 -0
- package/dist/commonjs/features/translation/providers/translation.interface.js +49 -0
- package/dist/commonjs/features/translation/providers/translation.interface.js.map +1 -0
- package/dist/commonjs/features/translation/types.js +2 -0
- package/dist/commonjs/features/translation/types.js.map +1 -0
- package/dist/commonjs/features/voice/index.js +4 -4
- package/dist/commonjs/features/voice/index.js.map +1 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js +44 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js +107 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js +66 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +58 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useDropdownAnimation.js} +8 -7
- package/dist/commonjs/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js +128 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → Dropdown.model.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/Dropdown.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/PlaybackController.js +183 -0
- package/dist/commonjs/features/voice/playing/model/PlaybackController.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/Player.model.js +24 -1
- package/dist/commonjs/features/voice/playing/model/Player.model.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js +82 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/Translation.model.js +62 -0
- package/dist/commonjs/features/voice/playing/model/Translation.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
- package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +46 -172
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/commonjs/features/voice/types.js.map +1 -1
- package/dist/commonjs/index.js +12 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/features/translation/constants.js +7 -0
- package/dist/module/features/translation/constants.js.map +1 -0
- package/dist/module/features/translation/helpers.js +53 -0
- package/dist/module/features/translation/helpers.js.map +1 -0
- package/dist/module/features/translation/index.js +12 -0
- package/dist/module/features/translation/index.js.map +1 -0
- package/dist/module/features/translation/model/TranslationModel.js +117 -0
- package/dist/module/features/translation/model/TranslationModel.js.map +1 -0
- package/dist/module/features/translation/model/TranslationPreprocessor.js +137 -0
- package/dist/module/features/translation/model/TranslationPreprocessor.js.map +1 -0
- package/dist/module/features/translation/model/TranslationService.js +107 -0
- package/dist/module/features/translation/model/TranslationService.js.map +1 -0
- package/dist/module/features/translation/preserve/wordsToPreserve.js +310 -0
- package/dist/module/features/translation/preserve/wordsToPreserve.js.map +1 -0
- package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js +45 -0
- package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
- package/dist/module/features/translation/providers/google/supportedLanguages.js +225 -0
- package/dist/module/features/translation/providers/google/supportedLanguages.js.map +1 -0
- package/dist/module/features/translation/providers/google.types.js +2 -0
- package/dist/module/features/translation/providers/google.types.js.map +1 -0
- package/dist/module/features/translation/providers/translation.interface.js +44 -0
- package/dist/module/features/translation/providers/translation.interface.js.map +1 -0
- package/dist/module/features/translation/types.js +2 -0
- package/dist/module/features/translation/types.js.map +1 -0
- package/dist/module/features/voice/index.js +1 -1
- package/dist/module/features/voice/index.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js +38 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscription.js +101 -0
- package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js +58 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +52 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useDropdownAnimation.js} +6 -5
- package/dist/module/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js +123 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
- package/dist/module/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → Dropdown.model.js} +2 -2
- package/dist/module/features/voice/playing/model/Dropdown.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/PlaybackController.js +178 -0
- package/dist/module/features/voice/playing/model/PlaybackController.js.map +1 -0
- package/dist/module/features/voice/playing/model/Player.model.js +24 -1
- package/dist/module/features/voice/playing/model/Player.model.js.map +1 -1
- package/dist/module/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +2 -2
- package/dist/module/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js +77 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/Translation.model.js +57 -0
- package/dist/module/features/voice/playing/model/Translation.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
- package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js +48 -174
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/module/features/voice/types.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/commonjs/features/translation/constants.d.ts +5 -0
- package/dist/typescript/commonjs/features/translation/constants.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/helpers.d.ts +9 -0
- package/dist/typescript/commonjs/features/translation/helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/index.d.ts +12 -0
- package/dist/typescript/commonjs/features/translation/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts +33 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts +34 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts +40 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts +3 -0
- package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
- package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts +209 -0
- package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts +15 -0
- package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts +30 -0
- package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/types.d.ts +27 -0
- package/dist/typescript/commonjs/features/translation/types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/index.d.ts +2 -1
- package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
- package/dist/typescript/{module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts → commonjs/features/voice/playing/components/VoiceTranscription.d.ts} +3 -4
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
- package/dist/typescript/{module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts → commonjs/features/voice/playing/hooks/useDropdownAnimation.d.ts} +3 -3
- package/dist/typescript/commonjs/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
- package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts → commonjs/features/voice/playing/model/Dropdown.model.d.ts} +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts +28 -0
- package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts +3 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts.map +1 -1
- package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts +25 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +18 -18
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/types.d.ts +5 -1
- package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/module/features/translation/constants.d.ts +5 -0
- package/dist/typescript/module/features/translation/constants.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/helpers.d.ts +9 -0
- package/dist/typescript/module/features/translation/helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/index.d.ts +12 -0
- package/dist/typescript/module/features/translation/index.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationModel.d.ts +33 -0
- package/dist/typescript/module/features/translation/model/TranslationModel.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts +34 -0
- package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationService.d.ts +40 -0
- package/dist/typescript/module/features/translation/model/TranslationService.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts +3 -0
- package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
- package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts +209 -0
- package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google.types.d.ts +15 -0
- package/dist/typescript/module/features/translation/providers/google.types.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/translation.interface.d.ts +30 -0
- package/dist/typescript/module/features/translation/providers/translation.interface.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/types.d.ts +27 -0
- package/dist/typescript/module/features/translation/types.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/index.d.ts +2 -1
- package/dist/typescript/module/features/voice/index.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
- package/dist/typescript/{commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts → module/features/voice/playing/components/VoiceTranscription.d.ts} +3 -4
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
- package/dist/typescript/{commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts → module/features/voice/playing/hooks/useDropdownAnimation.d.ts} +3 -3
- package/dist/typescript/module/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
- package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts → module/features/voice/playing/model/Dropdown.model.d.ts} +2 -2
- package/dist/typescript/module/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts +28 -0
- package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts +3 -0
- package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts.map +1 -1
- package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → module/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts +25 -0
- package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
- package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +18 -18
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/types.d.ts +5 -1
- package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/package.json +28 -1
- package/src/features/translation/constants.ts +4 -0
- package/src/features/translation/helpers.ts +63 -0
- package/src/features/translation/index.ts +30 -0
- package/src/features/translation/model/TranslationModel.ts +174 -0
- package/src/features/translation/model/TranslationPreprocessor.ts +171 -0
- package/src/features/translation/model/TranslationService.ts +148 -0
- package/src/features/translation/preserve/wordsToPreserve.ts +87 -0
- package/src/features/translation/providers/google/GoogleTranslationProvider.ts +50 -0
- package/src/features/translation/providers/google/supportedLanguages.ts +229 -0
- package/src/features/translation/providers/google.types.ts +16 -0
- package/src/features/translation/providers/translation.interface.ts +63 -0
- package/src/features/translation/types.ts +30 -0
- package/src/features/voice/index.ts +2 -1
- package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +37 -0
- package/src/features/voice/playing/components/VoiceTranscription.tsx +117 -0
- package/src/features/voice/playing/components/VoiceTranscriptionCollapsible.tsx +59 -0
- package/src/features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx +61 -0
- package/src/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.ts → useDropdownAnimation.ts} +5 -5
- package/src/features/voice/playing/hooks/useVoiceTranscriptionController.ts +171 -0
- package/src/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.ts → Dropdown.model.ts} +2 -2
- package/src/features/voice/playing/model/PlaybackController.ts +213 -0
- package/src/features/voice/playing/model/Player.model.ts +26 -1
- package/src/features/voice/playing/model/{VoiceTranscriptionsCollection.ts → TranscriptionsCollection.ts} +1 -1
- package/src/features/voice/playing/model/TranscriptionsDownloader.model.ts +88 -0
- package/src/features/voice/playing/model/Translation.model.ts +75 -0
- package/src/features/voice/playing/model/VoiceFileDownloader.model.ts +2 -2
- package/src/features/voice/playing/model/VoicePlayer.model.ts +57 -194
- package/src/features/voice/types.ts +10 -0
- package/src/index.ts +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -251
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -109
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -34
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -66
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -244
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -103
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -29
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -61
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -15
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -15
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
- package/src/features/voice/playing/components/VoiceTranscriptionsDropdown.tsx +0 -302
- package/src/features/voice/playing/components/VoiceTranscriptionsDropdownItem.tsx +0 -128
- package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.ts +0 -40
- package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +0 -80
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useUnit } from 'effector-react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { NO_AUDIO_BE_MESSAGE } from "../../constants.js";
|
|
7
|
+
import { getActiveAttempt } from "../../helpers.js";
|
|
8
|
+
import { resolveGoogleLanguageCode } from "../../../translation/providers/google/supportedLanguages.js";
|
|
9
|
+
import { useText } from "../../../../i18n/i18n.js";
|
|
10
|
+
export const useVoiceTranscriptionController = ({
|
|
11
|
+
model,
|
|
12
|
+
answers,
|
|
13
|
+
attemptOffset,
|
|
14
|
+
attemptsCount,
|
|
15
|
+
problemId
|
|
16
|
+
}) => {
|
|
17
|
+
const t = useText();
|
|
18
|
+
const {
|
|
19
|
+
i18n
|
|
20
|
+
} = useTranslation();
|
|
21
|
+
const [playerState, isLoadingTranscripts, isTranslationActive, translations, isTranslating] = useUnit([model.$playerState, model.loader.loadTranscriptForAttempt.pending, model.translation.$isActive, model.translation.$translations, model.translation.translate.pending]);
|
|
22
|
+
const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount);
|
|
23
|
+
const answersKey = useMemo(() => answers.map(a => `${a._id}:${a.audioFileId ?? ''}`).join(','), [answers]);
|
|
24
|
+
const activeAudioFileId = activeAttempt !== null ? answers?.[activeAttempt - 1]?.audioFileId : undefined;
|
|
25
|
+
const hasActiveAudio = activeAudioFileId !== undefined;
|
|
26
|
+
const anyAttemptHasAudio = useMemo(() => answers.some(a => !!a.audioFileId), [answers]);
|
|
27
|
+
const cachedEntry = activeAudioFileId ? model.loader.getCachedTranscript(activeAudioFileId) : undefined;
|
|
28
|
+
const activeTranscript = cachedEntry?.text ?? null;
|
|
29
|
+
const hasTranscriptText = !!activeTranscript && activeTranscript !== NO_AUDIO_BE_MESSAGE;
|
|
30
|
+
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript;
|
|
31
|
+
const isSourceSameAsTarget = !!cachedEntry?.language && resolveGoogleLanguageCode(cachedEntry.language) === resolveGoogleLanguageCode(i18n.language);
|
|
32
|
+
const canTranslate = hasTranscriptText && !isSourceSameAsTarget;
|
|
33
|
+
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined;
|
|
34
|
+
const showTranslation = isTranslationActive && canTranslate;
|
|
35
|
+
const isTranslationLoading = showTranslation && !cachedTranslation && isTranslating;
|
|
36
|
+
const displayText = showTranslation ? cachedTranslation ?? activeTranscript : hasTranscriptText ? activeTranscript : t('voice.transcriptNotAvailable');
|
|
37
|
+
|
|
38
|
+
// Lifecycle effects
|
|
39
|
+
const answersRef = useRef(answers);
|
|
40
|
+
answersRef.current = answers;
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
model.reinitializePlayer();
|
|
43
|
+
return () => {
|
|
44
|
+
model.stopAudio();
|
|
45
|
+
model.dropdown.setExpanded(false);
|
|
46
|
+
};
|
|
47
|
+
}, [model]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
model.dropdown.setExpanded(false);
|
|
50
|
+
model.resetPlayer();
|
|
51
|
+
}, [problemId]);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (answersRef.current.some(a => a.audioFileId)) {
|
|
54
|
+
model.initializeWithAudios(answersRef.current);
|
|
55
|
+
}
|
|
56
|
+
}, [model, answersKey]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
model.stopAudio();
|
|
59
|
+
model.setCurrentAttempt(activeAttempt);
|
|
60
|
+
if (activeAttempt !== null) {
|
|
61
|
+
model.loader.loadTranscriptForAttempt(activeAttempt);
|
|
62
|
+
}
|
|
63
|
+
}, [model, activeAttempt, answersKey]);
|
|
64
|
+
|
|
65
|
+
// Auto-activate translation once per (problemId, activeAttempt) when translatable
|
|
66
|
+
const autoActivatedAttempts = useRef(new Set());
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
autoActivatedAttempts.current.clear();
|
|
69
|
+
}, [problemId]);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (canTranslate && activeAttempt !== null && !autoActivatedAttempts.current.has(activeAttempt)) {
|
|
72
|
+
autoActivatedAttempts.current.add(activeAttempt);
|
|
73
|
+
model.translation.setActive(true);
|
|
74
|
+
}
|
|
75
|
+
}, [canTranslate, activeAttempt, model]);
|
|
76
|
+
|
|
77
|
+
// Trigger translate when we should show translation but don't have it cached
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
80
|
+
model.translation.translate({
|
|
81
|
+
attemptNumber: activeAttempt,
|
|
82
|
+
targetLanguage: i18n.language
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}, [showTranslation, activeAttempt, cachedTranslation, isTranslating, i18n.language, model]);
|
|
86
|
+
|
|
87
|
+
// Auto-open dropdown when a translation successfully completes
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
return model.translation.translate.doneData.watch(result => {
|
|
90
|
+
if (result) {
|
|
91
|
+
model.dropdown.setExpanded(true);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}, [model]);
|
|
95
|
+
const onPlayPress = useCallback(() => {
|
|
96
|
+
if (activeAttempt) {
|
|
97
|
+
model.translation.setActive(false);
|
|
98
|
+
model.togglePlayPause(activeAttempt);
|
|
99
|
+
}
|
|
100
|
+
}, [model, activeAttempt]);
|
|
101
|
+
const onTranslationToggle = useCallback(() => {
|
|
102
|
+
model.translation.toggle();
|
|
103
|
+
model.dropdown.setExpanded(true);
|
|
104
|
+
}, [model]);
|
|
105
|
+
return {
|
|
106
|
+
display: {
|
|
107
|
+
text: displayText,
|
|
108
|
+
isLoading: isActiveTranscriptLoading || isTranslationLoading
|
|
109
|
+
},
|
|
110
|
+
flags: {
|
|
111
|
+
playerState: playerState,
|
|
112
|
+
hasActiveAudio,
|
|
113
|
+
anyAttemptHasAudio,
|
|
114
|
+
canTranslate,
|
|
115
|
+
isTranslationActive
|
|
116
|
+
},
|
|
117
|
+
actions: {
|
|
118
|
+
onPlayPress,
|
|
119
|
+
onTranslationToggle
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=useVoiceTranscriptionController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useUnit","useCallback","useEffect","useMemo","useRef","useTranslation","NO_AUDIO_BE_MESSAGE","getActiveAttempt","resolveGoogleLanguageCode","useText","useVoiceTranscriptionController","model","answers","attemptOffset","attemptsCount","problemId","t","i18n","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","$playerState","loader","loadTranscriptForAttempt","pending","translation","$isActive","$translations","translate","activeAttempt","answersKey","map","a","_id","audioFileId","join","activeAudioFileId","undefined","hasActiveAudio","anyAttemptHasAudio","some","cachedEntry","getCachedTranscript","activeTranscript","text","hasTranscriptText","isActiveTranscriptLoading","isSourceSameAsTarget","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","answersRef","current","reinitializePlayer","stopAudio","dropdown","setExpanded","resetPlayer","initializeWithAudios","setCurrentAttempt","autoActivatedAttempts","Set","clear","has","add","setActive","attemptNumber","targetLanguage","doneData","watch","result","onPlayPress","togglePlayPause","onTranslationToggle","toggle","display","isLoading","flags","actions"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionController.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,gBAAgB;AACxC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC/D,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,mBAAmB,QAAQ,oBAAiB;AACrD,SAASC,gBAAgB,QAAQ,kBAAe;AAEhD,SAASC,yBAAyB,QAAQ,6DAA0D;AACpG,SAASC,OAAO,QAAQ,0BAAuB;AAc/C,OAAO,MAAMC,+BAA+B,GAAGA,CAAC;EAC9C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AAE;MACPP,WAAW;MACXE;IACF;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { createEvent, restore } from 'effector';
|
|
4
|
-
export class
|
|
4
|
+
export class DropdownModel {
|
|
5
5
|
toggleExpand = createEvent();
|
|
6
6
|
setExpanded = createEvent();
|
|
7
7
|
reset = createEvent();
|
|
8
8
|
$isExpanded = restore(this.setExpanded, false).on(this.toggleExpand, state => !state).reset(this.reset);
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=Dropdown.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createEvent","restore","DropdownModel","toggleExpand","setExpanded","reset","$isExpanded","on","state"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Dropdown.model.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,UAAU;AAE/C,OAAO,MAAMC,aAAa,CAAC;EACTC,YAAY,GAAGH,WAAW,CAAC,CAAC;EAC5BI,WAAW,GAAGJ,WAAW,CAAU,CAAC;EACpCK,KAAK,GAAGL,WAAW,CAAC,CAAC;EAErBM,WAAW,GAAGL,OAAO,CAAC,IAAI,CAACG,WAAW,EAAE,KAAK,CAAC,CAC3DG,EAAE,CAAC,IAAI,CAACJ,YAAY,EAAGK,KAAK,IAAK,CAACA,KAAK,CAAC,CACxCH,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createEffect } from 'effector';
|
|
4
|
+
import { PlayerState } from "./Player.model.js";
|
|
5
|
+
export class PlaybackController {
|
|
6
|
+
currentPlayingAttempt = null;
|
|
7
|
+
shouldPreventPlayback = false;
|
|
8
|
+
constructor(deps) {
|
|
9
|
+
this.collection = deps.collection;
|
|
10
|
+
this.player = deps.player;
|
|
11
|
+
this.downloader = deps.downloader;
|
|
12
|
+
this.player.playbackFinished.watch(() => this.clearCurrentAttempt());
|
|
13
|
+
}
|
|
14
|
+
togglePlayPause = attemptNumber => {
|
|
15
|
+
const playerState = this.player.$playerState.getState();
|
|
16
|
+
if (this.currentPlayingAttempt === attemptNumber && playerState === PlayerState.PLAYING) {
|
|
17
|
+
this.player.pause();
|
|
18
|
+
} else {
|
|
19
|
+
this.handlePlayAttempt(attemptNumber);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
preloadAudio = createEffect(async attemptNumber => {
|
|
23
|
+
const item = this.collection.get(attemptNumber);
|
|
24
|
+
if (!item) return;
|
|
25
|
+
if (this.collection.hasAudio(attemptNumber)) {
|
|
26
|
+
this.primePlayerIfIdle(attemptNumber);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (item.audioDownloadPromise) {
|
|
30
|
+
try {
|
|
31
|
+
await item.audioDownloadPromise;
|
|
32
|
+
} catch {}
|
|
33
|
+
this.primePlayerIfIdle(attemptNumber);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
await this.downloadAudio(attemptNumber);
|
|
38
|
+
this.primePlayerIfIdle(attemptNumber);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error instanceof Error && error.name === 'AbortError') return;
|
|
41
|
+
console.error('Audio preload error:', error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
primePlayerIfIdle(attemptNumber) {
|
|
45
|
+
if (this.player.$playerState.getState() !== PlayerState.IDLE) return;
|
|
46
|
+
if (this.currentPlayingAttempt !== null) return;
|
|
47
|
+
const audioUri = this.collection.get(attemptNumber)?.audioUri;
|
|
48
|
+
if (!audioUri) return;
|
|
49
|
+
this.player.prime(audioUri);
|
|
50
|
+
}
|
|
51
|
+
halt() {
|
|
52
|
+
this.shouldPreventPlayback = true;
|
|
53
|
+
this.abortAllDownloads();
|
|
54
|
+
this.player.stop();
|
|
55
|
+
this.clearCurrentAttempt();
|
|
56
|
+
}
|
|
57
|
+
releaseResources() {
|
|
58
|
+
this.collection.getAll().forEach(item => {
|
|
59
|
+
if (item.controller) {
|
|
60
|
+
this.downloader.abortDownload(item.controller);
|
|
61
|
+
}
|
|
62
|
+
if (item.audioUri?.startsWith('blob:')) {
|
|
63
|
+
try {
|
|
64
|
+
URL.revokeObjectURL(item.audioUri);
|
|
65
|
+
} catch (e) {}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
clearCurrentAttempt() {
|
|
70
|
+
this.currentPlayingAttempt = null;
|
|
71
|
+
}
|
|
72
|
+
abortAllDownloads() {
|
|
73
|
+
this.collection.getAll().forEach(item => {
|
|
74
|
+
if (item.controller && item.audioLoading) {
|
|
75
|
+
this.downloader.abortDownload(item.controller);
|
|
76
|
+
this.collection.update(item.attemptNumber, {
|
|
77
|
+
audioLoading: false,
|
|
78
|
+
controller: undefined,
|
|
79
|
+
audioDownloadPromise: undefined
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async downloadAudio(attemptNumber) {
|
|
85
|
+
const item = this.collection.get(attemptNumber);
|
|
86
|
+
if (!item) return;
|
|
87
|
+
const {
|
|
88
|
+
collectionItem,
|
|
89
|
+
downloadPromise
|
|
90
|
+
} = await this.downloader.download({
|
|
91
|
+
audioFileId: item.audioFileId,
|
|
92
|
+
attemptNumber
|
|
93
|
+
});
|
|
94
|
+
this.collection.update(attemptNumber, collectionItem);
|
|
95
|
+
try {
|
|
96
|
+
const result = await downloadPromise;
|
|
97
|
+
this.collection.update(attemptNumber, {
|
|
98
|
+
audioUri: result.uri,
|
|
99
|
+
audioLoading: false,
|
|
100
|
+
audioError: undefined,
|
|
101
|
+
controller: undefined,
|
|
102
|
+
audioDownloadPromise: undefined
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
const isAbort = error instanceof Error && error.name === 'AbortError';
|
|
106
|
+
this.collection.update(attemptNumber, {
|
|
107
|
+
audioLoading: false,
|
|
108
|
+
audioError: isAbort ? undefined : error instanceof Error ? error.message : 'Failed to download audio',
|
|
109
|
+
controller: undefined,
|
|
110
|
+
audioDownloadPromise: undefined
|
|
111
|
+
});
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
handlePlayAttempt = createEffect(async attemptNumber => {
|
|
116
|
+
this.shouldPreventPlayback = false;
|
|
117
|
+
const item = this.collection.get(attemptNumber);
|
|
118
|
+
if (!item) return;
|
|
119
|
+
if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
|
|
120
|
+
this.abortAllDownloads();
|
|
121
|
+
}
|
|
122
|
+
if (this.collection.hasAudio(attemptNumber)) {
|
|
123
|
+
this.playAudioFx(attemptNumber);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
this.player.setPlayerState(PlayerState.LOADING);
|
|
128
|
+
if (item.audioDownloadPromise) {
|
|
129
|
+
await item.audioDownloadPromise;
|
|
130
|
+
} else {
|
|
131
|
+
await this.downloadAudio(attemptNumber);
|
|
132
|
+
}
|
|
133
|
+
if (this.shouldPreventPlayback) {
|
|
134
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
138
|
+
this.playAudioFx(attemptNumber);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
141
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
console.error('Audio download error:', error);
|
|
145
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
playAudioFx = createEffect(async attemptNumber => {
|
|
149
|
+
if (this.shouldPreventPlayback) return;
|
|
150
|
+
const item = this.collection.get(attemptNumber);
|
|
151
|
+
if (!item?.audioUri) {
|
|
152
|
+
console.warn('No audio URI available for attempt:', attemptNumber);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
|
|
157
|
+
this.player.player?.remove();
|
|
158
|
+
}
|
|
159
|
+
if (this.currentPlayingAttempt === attemptNumber && this.player.player?.playing) {
|
|
160
|
+
this.player.pause();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (this.currentPlayingAttempt === attemptNumber && !this.player.player?.playing) {
|
|
164
|
+
this.player.resume();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.currentPlayingAttempt = attemptNumber;
|
|
168
|
+
await this.player.play(item.audioUri);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.error('Error playing audio:', error);
|
|
171
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
172
|
+
this.collection.update(attemptNumber, {
|
|
173
|
+
audioError: error instanceof Error ? error.message : 'Failed to play audio'
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=PlaybackController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createEffect","PlayerState","PlaybackController","currentPlayingAttempt","shouldPreventPlayback","constructor","deps","collection","player","downloader","playbackFinished","watch","clearCurrentAttempt","togglePlayPause","attemptNumber","playerState","$playerState","getState","PLAYING","pause","handlePlayAttempt","preloadAudio","item","get","hasAudio","primePlayerIfIdle","audioDownloadPromise","downloadAudio","error","Error","name","console","IDLE","audioUri","prime","halt","abortAllDownloads","stop","releaseResources","getAll","forEach","controller","abortDownload","startsWith","URL","revokeObjectURL","e","audioLoading","update","undefined","collectionItem","downloadPromise","download","audioFileId","result","uri","audioError","isAbort","message","playAudioFx","setPlayerState","LOADING","warn","remove","playing","resume","play"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/PlaybackController.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,UAAU;AACvC,SAAsBC,WAAW,QAAQ,mBAAgB;AAUzD,OAAO,MAAMC,kBAAkB,CAAC;EAItBC,qBAAqB,GAAkB,IAAI;EAC3CC,qBAAqB,GAAG,KAAK;EAErCC,WAAWA,CAACC,IAA4B,EAAE;IACxC,IAAI,CAACC,UAAU,GAAGD,IAAI,CAACC,UAAU;IACjC,IAAI,CAACC,MAAM,GAAGF,IAAI,CAACE,MAAM;IACzB,IAAI,CAACC,UAAU,GAAGH,IAAI,CAACG,UAAU;IACjC,IAAI,CAACD,MAAM,CAACE,gBAAgB,CAACC,KAAK,CAAC,MAAM,IAAI,CAACC,mBAAmB,CAAC,CAAC,CAAC;EACtE;EAEgBC,eAAe,GAAIC,aAAqB,IAAK;IAC3D,MAAMC,WAAW,GAAG,IAAI,CAACP,MAAM,CAACQ,YAAY,CAACC,QAAQ,CAAC,CAAC;IACvD,IAAI,IAAI,CAACd,qBAAqB,KAAKW,aAAa,IAAIC,WAAW,KAAKd,WAAW,CAACiB,OAAO,EAAE;MACvF,IAAI,CAACV,MAAM,CAACW,KAAK,CAAC,CAAC;IACrB,CAAC,MAAM;MACL,IAAI,CAACC,iBAAiB,CAACN,aAAa,CAAC;IACvC;EACF,CAAC;EAEeO,YAAY,GAAGrB,YAAY,CAAC,MAAOc,aAAqB,IAAK;IAC3E,MAAMQ,IAAI,GAAG,IAAI,CAACf,UAAU,CAACgB,GAAG,CAACT,aAAa,CAAC;IAC/C,IAAI,CAACQ,IAAI,EAAE;IACX,IAAI,IAAI,CAACf,UAAU,CAACiB,QAAQ,CAACV,aAAa,CAAC,EAAE;MAC3C,IAAI,CAACW,iBAAiB,CAACX,aAAa,CAAC;MACrC;IACF;IACA,IAAIQ,IAAI,CAACI,oBAAoB,EAAE;MAC7B,IAAI;QACF,MAAMJ,IAAI,CAACI,oBAAoB;MACjC,CAAC,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ACF;MAEA,IAAI,IAAI,CAAChB,qBAAqB,KAAKW,aAAa,IAAI,CAAC,IAAI,CAACN,MAAM,CAACA,MAAM,EAAEwD,OAAO,EAAE;QAChF,IAAI,CAACxD,MAAM,CAACyD,MAAM,CAAC,CAAC;QACpB;MACF;MAEA,IAAI,CAAC9D,qBAAqB,GAAGW,aAAa;MAC1C,MAAM,IAAI,CAACN,MAAM,CAAC0D,IAAI,CAAC5C,IAAI,CAACW,QAAQ,CAAC;IACvC,CAAC,CAAC,OAAOL,KAAK,EAAE;MACdG,OAAO,CAACH,KAAK,CAAC,sBAAsB,EAAEA,KAAK,CAAC;MAC5C,IAAI,CAACpB,MAAM,CAACoD,cAAc,CAAC3D,WAAW,CAAC+B,IAAI,CAAC;MAE5C,IAAI,CAACzB,UAAU,CAACyC,MAAM,CAAClC,aAAa,EAAE;QACpC0C,UAAU,EAAE5B,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAAC8B,OAAO,GAAG;MACvD,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ export let PlayerState = /*#__PURE__*/function (PlayerState) {
|
|
|
12
12
|
export class PlayerModel {
|
|
13
13
|
player = createAudioPlayer();
|
|
14
14
|
stopped = false;
|
|
15
|
+
primedUri = null;
|
|
15
16
|
reset = createEvent();
|
|
16
17
|
setPlayerState = createEvent();
|
|
17
18
|
playbackFinished = createEvent();
|
|
@@ -35,11 +36,29 @@ export class PlayerModel {
|
|
|
35
36
|
this.stopped = true;
|
|
36
37
|
if (this.player) {
|
|
37
38
|
this.player.replace('');
|
|
39
|
+
this.primedUri = null;
|
|
38
40
|
this.setPlayerState(PlayerState.IDLE);
|
|
39
41
|
} else {
|
|
40
42
|
console.warn('Cannot stop: audio player not initialized');
|
|
41
43
|
}
|
|
42
44
|
});
|
|
45
|
+
prime = createEffect(uri => {
|
|
46
|
+
if (!this.player) return;
|
|
47
|
+
if (this.primedUri === uri) return;
|
|
48
|
+
this.primedUri = uri;
|
|
49
|
+
this.player.replace(uri);
|
|
50
|
+
});
|
|
51
|
+
seek = createEffect(async seconds => {
|
|
52
|
+
if (!this.player) {
|
|
53
|
+
console.warn('Cannot seek: audio player not initialized');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!this.player.isLoaded) {
|
|
57
|
+
console.warn('Cannot seek: audio player not loaded');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
await this.player.seekTo(seconds);
|
|
61
|
+
});
|
|
43
62
|
resume = createEffect(() => {
|
|
44
63
|
if (this.player) {
|
|
45
64
|
this.player.play();
|
|
@@ -54,7 +73,10 @@ export class PlayerModel {
|
|
|
54
73
|
return;
|
|
55
74
|
}
|
|
56
75
|
this.stopped = false;
|
|
57
|
-
this.
|
|
76
|
+
if (this.primedUri !== uri) {
|
|
77
|
+
this.player.replace(uri);
|
|
78
|
+
this.primedUri = uri;
|
|
79
|
+
}
|
|
58
80
|
const waitForLoad = () => {
|
|
59
81
|
if (this.stopped) return;
|
|
60
82
|
if (this.player && this.player.isLoaded) {
|
|
@@ -87,6 +109,7 @@ export class PlayerModel {
|
|
|
87
109
|
this.player.release();
|
|
88
110
|
this.player = null;
|
|
89
111
|
}
|
|
112
|
+
this.primedUri = null;
|
|
90
113
|
this.reset();
|
|
91
114
|
}
|
|
92
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEffect","createEvent","restore","createAudioPlayer","setAudioModeAsync","PlayerState","PlayerModel","player","stopped","reset","setPlayerState","playbackFinished","$playerState","IDLE","setupAudioMode","playsInSilentMode","shouldPlayInBackground","interruptionMode","pause","PAUSED","console","warn","stop","replace","
|
|
1
|
+
{"version":3,"names":["createEffect","createEvent","restore","createAudioPlayer","setAudioModeAsync","PlayerState","PlayerModel","player","stopped","primedUri","reset","setPlayerState","playbackFinished","$playerState","IDLE","setupAudioMode","playsInSilentMode","shouldPlayInBackground","interruptionMode","pause","PAUSED","console","warn","stop","replace","prime","uri","seek","seconds","isLoaded","seekTo","resume","play","PLAYING","waitForLoad","unsubscribe","addListener","status","didJustFinish","remove","setTimeout","reinitialize","release","error"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Player.model.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAU;AAC7D,SAAsBC,iBAAiB,EAAEC,iBAAiB,QAAQ,YAAY;AAE9E,WAAkBC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAO7B,OAAO,MAAMC,WAAW,CAAC;EAChBC,MAAM,GAAuBJ,iBAAiB,CAAC,CAAC;EAC/CK,OAAO,GAAG,KAAK;EACfC,SAAS,GAAkB,IAAI;EAEvBC,KAAK,GAAGT,WAAW,CAAC,CAAC;EACrBU,cAAc,GAAGV,WAAW,CAAc,CAAC;EAC3CW,gBAAgB,GAAGX,WAAW,CAAC,CAAC;EAEhCY,YAAY,GAAGX,OAAO,CAAC,IAAI,CAACS,cAAc,EAAEN,WAAW,CAACS,IAAI,CAAC,CAACJ,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EAE/EK,cAAc,GAAGf,YAAY,CAAC,YAAY;IACxD,MAAMI,iBAAiB,CAAC;MACtBY,iBAAiB,EAAE,IAAI;MACvBC,sBAAsB,EAAE,KAAK;MAC7BC,gBAAgB,EAAE;IACpB,CAAC,CAAC;EACJ,CAAC,CAAC;EAEcC,KAAK,GAAGnB,YAAY,CAAC,MAAM;IACzC,IAAI,IAAI,CAACO,MAAM,EAAE;MACf,IAAI,CAACA,MAAM,CAACY,KAAK,CAAC,CAAC;MACnB,IAAI,CAACR,cAAc,CAACN,WAAW,CAACe,MAAM,CAAC;IACzC,CAAC,MAAM;MACLC,OAAO,CAACC,IAAI,CAAC,4CAA4C,CAAC;IAC5D;EACF,CAAC,CAAC;EAEcC,IAAI,GAAGvB,YAAY,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I,CAAChB,MAAM,CAACgC,MAAM,CAAC,CAAC;MACtB,CAAC,CAAC,OAAOI,KAAK,EAAE,CAAC;MACjB,IAAI,CAACpC,MAAM,CAACmC,OAAO,CAAC,CAAC;MACrB,IAAI,CAACnC,MAAM,GAAG,IAAI;IACpB;IACA,IAAI,CAACE,SAAS,GAAG,IAAI;IACrB,IAAI,CAACC,KAAK,CAAC,CAAC;EACd;AACF","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export class
|
|
3
|
+
export class TranscriptionsCollection {
|
|
4
4
|
collection = new Map();
|
|
5
5
|
add(attemptNumber, item) {
|
|
6
6
|
this.collection.set(attemptNumber, item);
|
|
@@ -33,4 +33,4 @@ export class VoiceTranscriptionsCollection {
|
|
|
33
33
|
return !!item?.audioUri;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
//# sourceMappingURL=
|
|
36
|
+
//# sourceMappingURL=TranscriptionsCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TranscriptionsCollection","collection","Map","add","attemptNumber","item","set","update","existingItem","get","delete","getAll","Array","from","values","clear","hasTranscript","transcript","hasAudio","audioUri"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsCollection.ts"],"mappings":";;AAEA,OAAO,MAAMA,wBAAwB,CAAC;EACpBC,UAAU,GAAwC,IAAIC,GAAG,CAAC,CAAC;EAEpEC,GAAGA,CAACC,aAAqB,EAAEC,IAA4B,EAAE;IAC9D,IAAI,CAACJ,UAAU,CAACK,GAAG,CAACF,aAAa,EAAEC,IAAI,CAAC;EAC1C;EAEOE,MAAMA,CAACH,aAAqB,EAAEC,IAAqC,EAAE;IAC1E,MAAMG,YAAY,GAAG,IAAI,CAACP,UAAU,CAACQ,GAAG,CAACL,aAAa,CAAC,IAAK,CAAC,CAA4B;IACzF,IAAI,CAACH,UAAU,CAACK,GAAG,CAACF,aAAa,EAAE;MAAE,GAAGI,YAAY;MAAE,GAAGH;IAAK,CAAC,CAAC;EAClE;EAEOK,MAAMA,CAACN,aAAqB,EAAE;IACnC,IAAI,CAACH,UAAU,CAACS,MAAM,CAACN,aAAa,CAAC;EACvC;EAEOK,GAAGA,CAACL,aAAqB,EAAE;IAChC,OAAO,IAAI,CAACH,UAAU,CAACQ,GAAG,CAACL,aAAa,CAAC;EAC3C;EAEOO,MAAMA,CAAA,EAAG;IACd,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACZ,UAAU,CAACa,MAAM,CAAC,CAAC,CAAC;EAC7C;EAEOC,KAAKA,CAAA,EAAG;IACb,IAAI,CAACd,UAAU,CAACc,KAAK,CAAC,CAAC;EACzB;EAEOC,aAAaA,CAACZ,aAAqB,EAAE;IAC1C,MAAMC,IAAI,GAAG,IAAI,CAACJ,UAAU,CAACQ,GAAG,CAACL,aAAa,CAAC;IAC/C,OAAO,CAAC,CAACC,IAAI,EAAEY,UAAU;EAC3B;EAEOC,QAAQA,CAACd,aAAqB,EAAE;IACrC,MAAMC,IAAI,GAAG,IAAI,CAACJ,UAAU,CAACQ,GAAG,CAACL,aAAa,CAAC;IAC/C,OAAO,CAAC,CAACC,IAAI,EAAEc,QAAQ;EACzB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createEffect } from 'effector';
|
|
4
|
+
import { NO_AUDIO_BE_MESSAGE, TRANSCRIPT_MAX_RETRIES, TRANSCRIPT_RETRY_INTERVAL_MS } from "../../constants.js";
|
|
5
|
+
export class TranscriptionsDownloaderModel {
|
|
6
|
+
inflightFetches = new Map();
|
|
7
|
+
transcriptCache = new Map();
|
|
8
|
+
constructor(collection, api) {
|
|
9
|
+
this.collection = collection;
|
|
10
|
+
this.api = api;
|
|
11
|
+
}
|
|
12
|
+
fetchTranscriptWithRetry(audioFileId) {
|
|
13
|
+
const cached = this.transcriptCache.get(audioFileId);
|
|
14
|
+
if (cached) return Promise.resolve(cached);
|
|
15
|
+
const existing = this.inflightFetches.get(audioFileId);
|
|
16
|
+
if (existing) return existing;
|
|
17
|
+
const promise = this.runFetchWithRetry(audioFileId).then(result => {
|
|
18
|
+
this.transcriptCache.set(audioFileId, result);
|
|
19
|
+
return result;
|
|
20
|
+
}).finally(() => {
|
|
21
|
+
this.inflightFetches.delete(audioFileId);
|
|
22
|
+
});
|
|
23
|
+
this.inflightFetches.set(audioFileId, promise);
|
|
24
|
+
return promise;
|
|
25
|
+
}
|
|
26
|
+
async runFetchWithRetry(audioFileId) {
|
|
27
|
+
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
28
|
+
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
29
|
+
if (response.status === 'completed') {
|
|
30
|
+
return {
|
|
31
|
+
text: response.text,
|
|
32
|
+
language: response.language
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (response.status === 'failed') {
|
|
36
|
+
return {
|
|
37
|
+
text: NO_AUDIO_BE_MESSAGE
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
41
|
+
await new Promise(resolve => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
text: NO_AUDIO_BE_MESSAGE
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
loadTranscriptForAttempt = createEffect(async attemptNumber => {
|
|
49
|
+
const item = this.collection.get(attemptNumber);
|
|
50
|
+
if (!item?.audioFileId) return;
|
|
51
|
+
if (item.transcript || item.transcriptLoading) return;
|
|
52
|
+
this.collection.update(attemptNumber, {
|
|
53
|
+
transcriptLoading: true
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
const {
|
|
57
|
+
text,
|
|
58
|
+
language
|
|
59
|
+
} = await this.fetchTranscriptWithRetry(item.audioFileId);
|
|
60
|
+
this.collection.update(attemptNumber, {
|
|
61
|
+
transcript: text,
|
|
62
|
+
transcriptLanguage: language,
|
|
63
|
+
transcriptLoading: false,
|
|
64
|
+
transcriptError: undefined
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
this.collection.update(attemptNumber, {
|
|
68
|
+
transcriptLoading: false,
|
|
69
|
+
transcriptError: error instanceof Error ? error.message : 'Failed to load transcript'
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
getCachedTranscript(audioFileId) {
|
|
74
|
+
return this.transcriptCache.get(audioFileId);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=TranscriptionsDownloader.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createEffect","NO_AUDIO_BE_MESSAGE","TRANSCRIPT_MAX_RETRIES","TRANSCRIPT_RETRY_INTERVAL_MS","TranscriptionsDownloaderModel","inflightFetches","Map","transcriptCache","constructor","collection","api","fetchTranscriptWithRetry","audioFileId","cached","get","Promise","resolve","existing","promise","runFetchWithRetry","then","result","set","finally","delete","attempt","response","getAudioFileTranscript","status","text","language","setTimeout","loadTranscriptForAttempt","attemptNumber","item","transcript","transcriptLoading","update","transcriptLanguage","transcriptError","undefined","error","Error","message","getCachedTranscript"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsDownloader.model.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,UAAU;AAGvC,SACEC,mBAAmB,EACnBC,sBAAsB,EACtBC,4BAA4B,QACvB,oBAAiB;AAIxB,OAAO,MAAMC,6BAA6B,CAAC;EAGxBC,eAAe,GAAG,IAAIC,GAAG,CAAoC,CAAC;EAC9DC,eAAe,GAAG,IAAID,GAAG,CAA2B,CAAC;EAEtEE,WAAWA,CAACC,UAAoC,EAAEC,GAAmB,EAAE;IACrE,IAAI,CAACD,UAAU,GAAGA,UAAU;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+1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createEffect, createEvent, createStore, restore } from 'effector';
|
|
4
|
+
import { TranslationService } from "../../../translation/model/TranslationService.js";
|
|
5
|
+
import { GoogleTranslationProvider } from "../../../translation/providers/google/GoogleTranslationProvider.js";
|
|
6
|
+
import { preservedWordsReplacers, wordsToPreserve } from "../../../translation/preserve/wordsToPreserve.js";
|
|
7
|
+
export class TranslationModel {
|
|
8
|
+
toggle = createEvent();
|
|
9
|
+
setActive = createEvent();
|
|
10
|
+
clearCache = createEvent();
|
|
11
|
+
reset = createEvent();
|
|
12
|
+
$isActive = restore(this.setActive, false).on(this.toggle, state => !state).reset(this.reset);
|
|
13
|
+
translate = createEffect(async ({
|
|
14
|
+
attemptNumber,
|
|
15
|
+
targetLanguage
|
|
16
|
+
}) => {
|
|
17
|
+
const item = this.collection.get(attemptNumber);
|
|
18
|
+
if (!item?.transcript) return null;
|
|
19
|
+
const text = await this.service.translate(item.transcript, {
|
|
20
|
+
targetLang: targetLanguage,
|
|
21
|
+
sourceLang: item.transcriptLanguage,
|
|
22
|
+
cacheKey: `voice::${attemptNumber}::${targetLanguage}`
|
|
23
|
+
});
|
|
24
|
+
if (!text) return null;
|
|
25
|
+
return {
|
|
26
|
+
attemptNumber,
|
|
27
|
+
text
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
$translations = createStore({}).on(this.translate.doneData, (state, result) => {
|
|
31
|
+
if (!result) return state;
|
|
32
|
+
return {
|
|
33
|
+
...state,
|
|
34
|
+
[result.attemptNumber]: result.text
|
|
35
|
+
};
|
|
36
|
+
}).reset(this.reset, this.clearCache);
|
|
37
|
+
constructor(collection, api) {
|
|
38
|
+
this.collection = collection;
|
|
39
|
+
this.service = new TranslationService({
|
|
40
|
+
preserve: {
|
|
41
|
+
map: wordsToPreserve,
|
|
42
|
+
replacers: preservedWordsReplacers
|
|
43
|
+
},
|
|
44
|
+
providers: [new GoogleTranslationProvider({
|
|
45
|
+
api: {
|
|
46
|
+
translateRequest: api.translateText
|
|
47
|
+
}
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
50
|
+
this.clearCache.watch(() => this.service.reset());
|
|
51
|
+
this.reset.watch(() => this.service.reset());
|
|
52
|
+
}
|
|
53
|
+
getTranslation(attemptNumber) {
|
|
54
|
+
return this.$translations.getState()[attemptNumber];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=Translation.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createEffect","createEvent","createStore","restore","TranslationService","GoogleTranslationProvider","preservedWordsReplacers","wordsToPreserve","TranslationModel","toggle","setActive","clearCache","reset","$isActive","on","state","translate","attemptNumber","targetLanguage","item","collection","get","transcript","text","service","targetLang","sourceLang","transcriptLanguage","cacheKey","$translations","doneData","result","constructor","api","preserve","map","replacers","providers","translateRequest","translateText","watch","getTranslation","getState"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Translation.model.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAU;AAG1E,SAASC,kBAAkB,QAAQ,kDAA+C;AAClF,SAASC,yBAAyB,QAAQ,oEAAiE;AAC3G,SACEC,uBAAuB,EACvBC,eAAe,QACV,kDAA+C;AAYtD,OAAO,MAAMC,gBAAgB,CAAC;EAIZC,MAAM,GAAGR,WAAW,CAAC,CAAC;EACtBS,SAAS,GAAGT,WAAW,CAAU,CAAC;EAClCU,UAAU,GAAGV,WAAW,CAAC,CAAC;EAC1BW,KAAK,GAAGX,WAAW,CAAC,CAAC;EAErBY,SAAS,GAAGV,OAAO,CAAC,IAAI,CAACO,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,GAAGhB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AC,CAAC;IAC7F,CAAC,CAAC;IAEF,IAAI,CAAC5B,UAAU,CAAC6B,KAAK,CAAC,MAAM,IAAI,CAAChB,OAAO,CAACZ,KAAK,CAAC,CAAC,CAAC;IACjD,IAAI,CAACA,KAAK,CAAC4B,KAAK,CAAC,MAAM,IAAI,CAAChB,OAAO,CAACZ,KAAK,CAAC,CAAC,CAAC;EAC9C;EAEO6B,cAAcA,CAACxB,aAAqB,EAAsB;IAC/D,OAAO,IAAI,CAACY,aAAa,CAACa,QAAQ,CAAC,CAAC,CAACzB,aAAa,CAAC;EACrD;AACF","ignoreList":[]}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { createEffect } from 'effector';
|
|
4
4
|
import { downloadAudioFileRequestGenerator } from "../../helpers.js";
|
|
5
5
|
export class VoiceFileDownloaderModel {
|
|
6
|
-
|
|
6
|
+
constructor(api) {
|
|
7
7
|
this.api = api;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
download = createEffect(async ({
|
|
10
10
|
audioFileId,
|
|
11
11
|
attemptNumber
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEffect","downloadAudioFileRequestGenerator","VoiceFileDownloaderModel","
|
|
1
|
+
{"version":3,"names":["createEffect","downloadAudioFileRequestGenerator","VoiceFileDownloaderModel","constructor","api","download","audioFileId","attemptNumber","downloadAudio","controller","downloadPromise","collectionItem","audioLoading","audioDownloadPromise","abortDownload","abort"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoiceFileDownloader.model.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,UAAU;AAEvC,SAASC,iCAAiC,QAAQ,kBAAe;AAYjE,OAAO,MAAMC,wBAAwB,CAAC;EAGpCC,WAAWA,CAACC,GAAmB,EAAE;IAC/B,IAAI,CAACA,GAAG,GAAGA,GAAG;EAChB;EAEgBC,QAAQ,GAAGL,YAAY,CACrC,OAAO;IAAEM,WAAW;IAAEC;EAA8B,CAAC,KAA8B;IACjF,MAAM;MAAEC,aAAa;MAAEC;IAAW,CAAC,GAAGR,iCAAiC,CAACK,WAAW,EAAE,IAAI,CAACF,GAAG,CAAC;IAC9F,MAAMM,eAAe,GAAGF,aAAa,CAAC,CAAC;IAEvC,MAAMG,cAA+C,GAAG;MACtDJ,aAAa;MACbD,WAAW;MACXM,YAAY,EAAE,IAAI;MAClBC,oBAAoB,EAAEH,eAAe;MACrCD;IACF,CAAC;IAED,OAAO;MAAEE,cAAc;MAAED;IAAgB,CAAC;EAC5C,CACF,CAAC;EAEeI,aAAa,GAAIL,UAA4B,IAAK;IAChEA,UAAU,EAAEM,KAAK,CAAC,CAAC;EACrB,CAAC;AACH","ignoreList":[]}
|