Compare commits
1 Commits
main
...
feat/langu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2855b9d9c5 |
@@ -20,3 +20,34 @@ export const AVATARS = [
|
|||||||
name: "Joshua Heygen CEO",
|
name: "Joshua Heygen CEO",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const STT_LANGUAGE_LIST = [
|
||||||
|
{ label: 'Bulgarian', value: 'bg', key: 'bg' },
|
||||||
|
{ label: 'Chinese', value: 'zh', key: 'zh' },
|
||||||
|
{ label: 'Czech', value: 'cs', key: 'cs' },
|
||||||
|
{ label: 'Danish', value: 'da', key: 'da' },
|
||||||
|
{ label: 'Dutch', value: 'nl', key: 'nl' },
|
||||||
|
{ label: 'English', value: 'en', key: 'en' },
|
||||||
|
{ label: 'Finnish', value: 'fi', key: 'fi' },
|
||||||
|
{ label: 'French', value: 'fr', key: 'fr' },
|
||||||
|
{ label: 'German', value: 'de', key: 'de' },
|
||||||
|
{ label: 'Greek', value: 'el', key: 'el' },
|
||||||
|
{ label: 'Hindi', value: 'hi', key: 'hi' },
|
||||||
|
{ label: 'Hungarian', value: 'hu', key: 'hu' },
|
||||||
|
{ label: 'Indonesian', value: 'id', key: 'id' },
|
||||||
|
{ label: 'Italian', value: 'it', key: 'it' },
|
||||||
|
{ label: 'Japanese', value: 'ja', key: 'ja' },
|
||||||
|
{ label: 'Korean', value: 'ko', key: 'ko' },
|
||||||
|
{ label: 'Malay', value: 'ms', key: 'ms' },
|
||||||
|
{ label: 'Norwegian', value: 'no', key: 'no' },
|
||||||
|
{ label: 'Polish', value: 'pl', key: 'pl' },
|
||||||
|
{ label: 'Portuguese', value: 'pt', key: 'pt' },
|
||||||
|
{ label: 'Romanian', value: 'ro', key: 'ro' },
|
||||||
|
{ label: 'Russian', value: 'ru', key: 'ru' },
|
||||||
|
{ label: 'Slovak', value: 'sk', key: 'sk' },
|
||||||
|
{ label: 'Spanish', value: 'es', key: 'es' },
|
||||||
|
{ label: 'Swedish', value: 'sv', key: 'sv' },
|
||||||
|
{ label: 'Turkish', value: 'tr', key: 'tr' },
|
||||||
|
{ label: 'Ukrainian', value: 'uk', key: 'uk' },
|
||||||
|
{ label: 'Vietnamese', value: 'vi', key: 'vi' },
|
||||||
|
];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { StartAvatarResponse } from "@heygen/streaming-avatar";
|
|||||||
|
|
||||||
import StreamingAvatar, {
|
import StreamingAvatar, {
|
||||||
AvatarQuality,
|
AvatarQuality,
|
||||||
StreamingEvents, TaskType,
|
StreamingEvents, TaskType, VoiceEmotion,
|
||||||
} from "@heygen/streaming-avatar";
|
} from "@heygen/streaming-avatar";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -23,7 +23,7 @@ import { useMemoizedFn, usePrevious } from "ahooks";
|
|||||||
|
|
||||||
import InteractiveAvatarTextInput from "./InteractiveAvatarTextInput";
|
import InteractiveAvatarTextInput from "./InteractiveAvatarTextInput";
|
||||||
|
|
||||||
import { AVATARS } from "@/app/lib/constants";
|
import {AVATARS, STT_LANGUAGE_LIST} from "@/app/lib/constants";
|
||||||
|
|
||||||
export default function InteractiveAvatar() {
|
export default function InteractiveAvatar() {
|
||||||
const [isLoadingSession, setIsLoadingSession] = useState(false);
|
const [isLoadingSession, setIsLoadingSession] = useState(false);
|
||||||
@@ -32,6 +32,8 @@ export default function InteractiveAvatar() {
|
|||||||
const [debug, setDebug] = useState<string>();
|
const [debug, setDebug] = useState<string>();
|
||||||
const [knowledgeId, setKnowledgeId] = useState<string>("");
|
const [knowledgeId, setKnowledgeId] = useState<string>("");
|
||||||
const [avatarId, setAvatarId] = useState<string>("");
|
const [avatarId, setAvatarId] = useState<string>("");
|
||||||
|
const [language, setLanguage] = useState<string>('en');
|
||||||
|
|
||||||
const [data, setData] = useState<StartAvatarResponse>();
|
const [data, setData] = useState<StartAvatarResponse>();
|
||||||
const [text, setText] = useState<string>("");
|
const [text, setText] = useState<string>("");
|
||||||
const mediaStream = useRef<HTMLVideoElement>(null);
|
const mediaStream = useRef<HTMLVideoElement>(null);
|
||||||
@@ -90,6 +92,11 @@ export default function InteractiveAvatar() {
|
|||||||
quality: AvatarQuality.Low,
|
quality: AvatarQuality.Low,
|
||||||
avatarName: avatarId,
|
avatarName: avatarId,
|
||||||
knowledgeId: knowledgeId,
|
knowledgeId: knowledgeId,
|
||||||
|
voice: {
|
||||||
|
rate: 1.5, // 0.5 ~ 1.5
|
||||||
|
emotion: VoiceEmotion.EXCITED,
|
||||||
|
},
|
||||||
|
language: language,
|
||||||
});
|
});
|
||||||
|
|
||||||
setData(res);
|
setData(res);
|
||||||
@@ -241,6 +248,21 @@ export default function InteractiveAvatar() {
|
|||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
<Select
|
||||||
|
label="Select language"
|
||||||
|
placeholder="Select language"
|
||||||
|
className="max-w-xs"
|
||||||
|
selectedKeys={[language]}
|
||||||
|
onChange={(e) => {
|
||||||
|
setLanguage(e.target.value);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{STT_LANGUAGE_LIST.map((lang) => (
|
||||||
|
<SelectItem key={lang.key}>
|
||||||
|
{lang.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
className="bg-gradient-to-tr from-indigo-500 to-indigo-300 w-full text-white"
|
className="bg-gradient-to-tr from-indigo-500 to-indigo-300 w-full text-white"
|
||||||
|
|||||||
Reference in New Issue
Block a user