-
Notifications
You must be signed in to change notification settings - Fork 58
/
ElevenLabsAudioNative.tsx
49 lines (43 loc) · 1.24 KB
/
ElevenLabsAudioNative.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use client';
import { useEffect } from 'react';
export type ElevenLabsProps = {
publicUserId: string;
textColorRgba?: string;
backgroundColorRgba?: string;
size?: 'small' | 'large';
children?: React.ReactNode;
};
export const ElevenLabsAudioNative = ({
publicUserId,
size,
textColorRgba,
backgroundColorRgba,
children,
}: ElevenLabsProps) => {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://elevenlabs.io/player/audioNativeHelper.js';
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
};
}, []);
return (
<div
id="elevenlabs-audionative-widget"
data-height={size === 'small' ? '90' : '120'}
data-width="100%"
data-frameborder="no"
data-scrolling="no"
data-publicuserid={publicUserId}
data-playerurl="https://elevenlabs.io/player/index.html"
data-small={size === 'small' ? 'True' : 'False'}
data-textcolor={textColorRgba ?? 'rgba(0, 0, 0, 1.0)'}
data-backgroundcolor={backgroundColorRgba ?? 'rgba(255, 255, 255, 1.0)'}
>
{children ? children : 'Elevenlabs AudioNative Player'}
</div>
);
};
export default ElevenLabsAudioNative;