diff --git a/frontend/src/bundles/common/components/audio-player/audio-player.tsx b/frontend/src/bundles/common/components/audio-player/audio-player.tsx index c2655bfca..614209cc3 100644 --- a/frontend/src/bundles/common/components/audio-player/audio-player.tsx +++ b/frontend/src/bundles/common/components/audio-player/audio-player.tsx @@ -41,7 +41,9 @@ const AudioPlayer: React.FC = ({ getAudioData(audioUrl) .then(({ durationInSeconds }) => { setDurationInFrames(Math.round(durationInSeconds * FPS)); - onSetDuration && onSetDuration(durationInSeconds); + if (onSetDuration) { + onSetDuration(durationInSeconds); + } }) .catch(() => { setDurationInFrames(1); diff --git a/frontend/src/bundles/voices/components/voice-card/voice-card.tsx b/frontend/src/bundles/voices/components/voice-card/voice-card.tsx index 0c084c507..a7b766313 100644 --- a/frontend/src/bundles/voices/components/voice-card/voice-card.tsx +++ b/frontend/src/bundles/voices/components/voice-card/voice-card.tsx @@ -18,6 +18,7 @@ import { IconName, IconSize } from '~/bundles/common/icons/icons.js'; import { actions as homeActions } from '~/bundles/home/store/home.js'; import { type Voice } from '~/bundles/home/types/types.js'; import { Control } from '~/bundles/studio/components/control/control.js'; +import { TEXT_FOR_VOICES } from '~/bundles/voices/constants/constants.js'; type Properties = { voice: Voice; @@ -28,9 +29,6 @@ const VoiceCard: React.FC = ({ voice }) => { const [isLoading, setIsLoading] = useState(false); const dispatch = useAppDispatch(); - const text = - 'Hello, I can handle video speech for you, choose me if you like it!'; - const { isPlaying: playerIsPlaying, url: playerUrl } = useAppSelector( ({ home }) => home.voicePlayer, ); @@ -53,7 +51,7 @@ const VoiceCard: React.FC = ({ voice }) => { void dispatch( homeActions.generateScriptSpeechPreview({ scriptId: uuidv4(), - text, + text: TEXT_FOR_VOICES, voiceName: voice.shortName, }), ) @@ -69,16 +67,7 @@ const VoiceCard: React.FC = ({ voice }) => { ); }); }, - [ - dispatch, - text, - url, - voice, - isPlaying, - setUrl, - setIsLoading, - isLoading, - ], + [dispatch, url, voice, isPlaying, setUrl, setIsLoading, isLoading], ); const handleLikeClick = useCallback((): void => { dispatch(homeActions.toogleVoiceLike(voice.shortName)); diff --git a/frontend/src/bundles/voices/components/voice-section/voice-section.tsx b/frontend/src/bundles/voices/components/voice-section/voice-section.tsx index 76d67b5dc..051006891 100644 --- a/frontend/src/bundles/voices/components/voice-section/voice-section.tsx +++ b/frontend/src/bundles/voices/components/voice-section/voice-section.tsx @@ -6,6 +6,7 @@ import { SimpleGrid, Text, } from '~/bundles/common/components/components.js'; +import { EMPTY_VALUE } from '~/bundles/common/constants/constants.js'; import { type Voice } from '~/bundles/home/types/types.js'; import { VoiceCard } from '~/bundles/voices/components/components.js'; import { VoicesSections } from '~/bundles/voices/enums/voices-sections.js'; @@ -34,7 +35,7 @@ const VoiceSection: React.FC = ({ voices, title }) => { - {voices.length > 0 ? ( + {voices.length > EMPTY_VALUE ? ( title === VoicesSections.MY_VOICES ? ( {voices.map((voice) => ( diff --git a/frontend/src/bundles/voices/constants/constants.ts b/frontend/src/bundles/voices/constants/constants.ts new file mode 100644 index 000000000..624b13d5f --- /dev/null +++ b/frontend/src/bundles/voices/constants/constants.ts @@ -0,0 +1,2 @@ +export { TEXT_FOR_VOICES } from './text-for-voices.constant.js'; +export { EMPTY_VALUE } from 'shared'; diff --git a/frontend/src/bundles/voices/constants/text-for-voices.constant.ts b/frontend/src/bundles/voices/constants/text-for-voices.constant.ts new file mode 100644 index 000000000..e6f13b4a6 --- /dev/null +++ b/frontend/src/bundles/voices/constants/text-for-voices.constant.ts @@ -0,0 +1,4 @@ +const TEXT_FOR_VOICES = + 'Hello, I can handle video speech for you, choose me if you like it!'; + +export { TEXT_FOR_VOICES };