chore: audio
This commit is contained in:
+8
-8
@@ -25,14 +25,6 @@ export default [
|
|||||||
icon: 'Comment',
|
icon: 'Comment',
|
||||||
component: './playground/index'
|
component: './playground/index'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'speech',
|
|
||||||
title: 'Speech',
|
|
||||||
path: '/playground/speech',
|
|
||||||
key: 'speech',
|
|
||||||
icon: 'Comment',
|
|
||||||
component: './playground/speech'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'text2images',
|
name: 'text2images',
|
||||||
title: 'Text2Images',
|
title: 'Text2Images',
|
||||||
@@ -41,6 +33,14 @@ export default [
|
|||||||
icon: 'Comment',
|
icon: 'Comment',
|
||||||
component: './playground/images'
|
component: './playground/images'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'speech',
|
||||||
|
title: 'Speech',
|
||||||
|
path: '/playground/speech',
|
||||||
|
key: 'speech',
|
||||||
|
icon: 'Comment',
|
||||||
|
component: './playground/speech'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'embedding',
|
name: 'embedding',
|
||||||
title: 'embedding',
|
title: 'embedding',
|
||||||
|
|||||||
@@ -75,5 +75,12 @@ export default {
|
|||||||
'playground.rerank.rank': 'Rank',
|
'playground.rerank.rank': 'Rank',
|
||||||
'playground.rerank.score': 'Score',
|
'playground.rerank.score': 'Score',
|
||||||
'playground.rerank.query.holder': 'Input your query',
|
'playground.rerank.query.holder': 'Input your query',
|
||||||
'playground.image.prompt': 'Input Prompt'
|
'playground.image.prompt': 'Input Prompt',
|
||||||
|
'playground.audio.texttospeech': 'Text to Speech',
|
||||||
|
'playground.audio.speechtotext': 'Speech to Text',
|
||||||
|
'playground.audio.texttospeech.tips': 'Generated speech will appear here',
|
||||||
|
'playground.audio.speechtotext.tips':
|
||||||
|
'Upload an audio file or start recording',
|
||||||
|
'playground.audio.enablemic':
|
||||||
|
"Enable microphone access in your browser's settings."
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -75,5 +75,10 @@ export default {
|
|||||||
'playground.rerank.rank': '排序',
|
'playground.rerank.rank': '排序',
|
||||||
'playground.rerank.score': '分数',
|
'playground.rerank.score': '分数',
|
||||||
'playground.rerank.query.holder': '输入查询',
|
'playground.rerank.query.holder': '输入查询',
|
||||||
'playground.image.prompt': '输入提示'
|
'playground.image.prompt': '输入提示',
|
||||||
|
'playground.audio.texttospeech': '文本转语音',
|
||||||
|
'playground.audio.speechtotext': '语音转文本',
|
||||||
|
'playground.audio.texttospeech.tips': '生成的语音将出现在这里',
|
||||||
|
'playground.audio.speechtotext.tips': '上传音频文件或开始录音',
|
||||||
|
'playground.audio.enablemic': '请允许浏览器访问麦克风,以便开始录音'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -264,6 +264,11 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
value: backendOptionsMap.vllm,
|
value: backendOptionsMap.vllm,
|
||||||
disabled:
|
disabled:
|
||||||
source === modelSourceMap.local_path_value ? false : isGGUF
|
source === modelSourceMap.local_path_value ? false : isGGUF
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'vox-box',
|
||||||
|
value: backendOptionsMap.voxBox,
|
||||||
|
disabled: false
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
disabled={
|
disabled={
|
||||||
|
|||||||
@@ -423,6 +423,66 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const renderModelTags = useCallback((record: ListItem) => {
|
||||||
|
if (record.reranker) {
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
opacity: 0.8,
|
||||||
|
transform: 'scale(0.9)'
|
||||||
|
}}
|
||||||
|
color="geekblue"
|
||||||
|
>
|
||||||
|
Reranker
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (record.embedding_only && !record.reranker) {
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
opacity: 0.8,
|
||||||
|
transform: 'scale(0.9)'
|
||||||
|
}}
|
||||||
|
color="geekblue"
|
||||||
|
>
|
||||||
|
Embedding Only
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (record.text_to_speech) {
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
opacity: 0.8,
|
||||||
|
transform: 'scale(0.9)'
|
||||||
|
}}
|
||||||
|
color="geekblue"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: 'playground.audio.texttospeech' })}
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (record.speech_to_text) {
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
opacity: 0.8,
|
||||||
|
transform: 'scale(0.9)'
|
||||||
|
}}
|
||||||
|
color="geekblue"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: 'playground.audio.speechtotext' })}
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}, []);
|
||||||
const renderChildren = useCallback(
|
const renderChildren = useCallback(
|
||||||
(list: any, parent?: any) => {
|
(list: any, parent?: any) => {
|
||||||
return (
|
return (
|
||||||
@@ -548,30 +608,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
<AutoTooltip ghost>
|
<AutoTooltip ghost>
|
||||||
<span className="m-r-5">{text}</span>
|
<span className="m-r-5">{text}</span>
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
{record.reranker && (
|
{renderModelTags(record)}
|
||||||
<Tag
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
opacity: 0.8,
|
|
||||||
transform: 'scale(0.9)'
|
|
||||||
}}
|
|
||||||
color="geekblue"
|
|
||||||
>
|
|
||||||
Reranker
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
{record.embedding_only && !record.reranker && (
|
|
||||||
<Tag
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
opacity: 0.8,
|
|
||||||
transform: 'scale(0.9)'
|
|
||||||
}}
|
|
||||||
color="geekblue"
|
|
||||||
>
|
|
||||||
Embedding Only
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ export const ollamaModelOptions = [
|
|||||||
|
|
||||||
export const backendOptionsMap = {
|
export const backendOptionsMap = {
|
||||||
llamaBox: 'llama-box',
|
llamaBox: 'llama-box',
|
||||||
vllm: 'vllm'
|
vllm: 'vllm',
|
||||||
|
voxBox: 'vox-box'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const modelSourceMap: Record<string, string> = {
|
export const modelSourceMap: Record<string, string> = {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ export interface ListItem {
|
|||||||
model_scope_model_id: string;
|
model_scope_model_id: string;
|
||||||
embedding_only?: boolean;
|
embedding_only?: boolean;
|
||||||
ready_replicas: number;
|
ready_replicas: number;
|
||||||
|
speech_to_text?: boolean;
|
||||||
|
text_to_speech?: boolean;
|
||||||
replicas: number;
|
replicas: number;
|
||||||
s3Address: string;
|
s3Address: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ export const OPENAI_MODELS = '/v1-openai/models';
|
|||||||
|
|
||||||
export const RERANKER_API = '/rerank';
|
export const RERANKER_API = '/rerank';
|
||||||
|
|
||||||
|
export const AUDIO_TEXT_TO_SPEECH_API = '/v1-openai/audio/speech';
|
||||||
|
|
||||||
|
export const AUDIO_SPEECH_TO_TEXT_API = '/v1-openai/audio/transcriptions';
|
||||||
|
|
||||||
export async function execChatCompletions(params: any) {
|
export async function execChatCompletions(params: any) {
|
||||||
return request(`${CHAT_API}`, {
|
return request(`${CHAT_API}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -81,3 +85,28 @@ export const createImages = async (
|
|||||||
}
|
}
|
||||||
return res.json();
|
return res.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ============ audio ============
|
||||||
|
export const textToSpeech = async (params: any, options?: any) => {
|
||||||
|
const res = await fetch(AUDIO_TEXT_TO_SPEECH_API, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(params),
|
||||||
|
signal: params.signal
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error('Network response was not ok');
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const speechToText = async (params: any, options?: any) => {
|
||||||
|
const res = await fetch(AUDIO_SPEECH_TO_TEXT_API, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(params),
|
||||||
|
signal: params.signal
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error('Network response was not ok');
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
};
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
|
|
||||||
const result: any = await fetchChunkedData({
|
const result: any = await fetchChunkedData({
|
||||||
data: params,
|
data: params,
|
||||||
// url: 'http://192.168.50.27:40639/v1/images/generations',
|
// url: 'http://192.168.1.3:40487/v1/images/generations',
|
||||||
url: CREAT_IMAGE_API,
|
url: CREAT_IMAGE_API,
|
||||||
signal: requestToken.current.signal,
|
signal: requestToken.current.signal,
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -321,7 +321,9 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
return (
|
return (
|
||||||
<div className="tips-text">
|
<div className="tips-text">
|
||||||
<IconFont type={'icon-audio'} style={{ fontSize: 20 }}></IconFont>
|
<IconFont type={'icon-audio'} style={{ fontSize: 20 }}></IconFont>
|
||||||
<span>Upload an audio file or start recording</span>
|
<span>
|
||||||
|
{intl.formatMessage({ id: 'playground.audio.speechtotext.tips' })}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -469,7 +471,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
fontWeight: 500
|
fontWeight: 500
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Enable microphone access in your browser’s settings.
|
{intl.formatMessage({ id: 'playground.audio.enablemic' })}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -544,6 +546,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
payLoad={{
|
payLoad={{
|
||||||
messages: viewCodeMessage
|
messages: viewCodeMessage
|
||||||
}}
|
}}
|
||||||
|
api="audio/transcriptions"
|
||||||
parameters={parameters}
|
parameters={parameters}
|
||||||
onCancel={handleCloseViewCode}
|
onCancel={handleCloseViewCode}
|
||||||
title={intl.formatMessage({ id: 'playground.viewcode' })}
|
title={intl.formatMessage({ id: 'playground.viewcode' })}
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
import IconFont from '@/components/icon-font';
|
import IconFont from '@/components/icon-font';
|
||||||
import SpeechContent from '@/components/speech-content';
|
import SpeechContent from '@/components/speech-content';
|
||||||
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
||||||
import { fetchChunkedData, readStreamData } from '@/utils/fetch-chunk-data';
|
import { fetchChunkedData } from '@/utils/fetch-chunk-data';
|
||||||
import { ThunderboltOutlined } from '@ant-design/icons';
|
import { ThunderboltOutlined } from '@ant-design/icons';
|
||||||
import { useIntl, useSearchParams } from '@umijs/max';
|
import { useIntl, useSearchParams } from '@umijs/max';
|
||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import _ from 'lodash';
|
|
||||||
import 'overlayscrollbars/overlayscrollbars.css';
|
import 'overlayscrollbars/overlayscrollbars.css';
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
memo,
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
useMemo,
|
|
||||||
useRef,
|
useRef,
|
||||||
useState
|
useState
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { CHAT_API } from '../apis';
|
import { CHAT_API } from '../apis';
|
||||||
import { Roles, generateMessages } from '../config';
|
|
||||||
import { TTSParamsConfig as paramsConfig } from '../config/params-config';
|
import { TTSParamsConfig as paramsConfig } from '../config/params-config';
|
||||||
import { MessageItem } from '../config/types';
|
import { MessageItem } from '../config/types';
|
||||||
import '../style/ground-left.less';
|
import '../style/ground-left.less';
|
||||||
@@ -43,7 +40,16 @@ const initialValues = {
|
|||||||
const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||||
const { modelList } = props;
|
const { modelList } = props;
|
||||||
const messageId = useRef<number>(0);
|
const messageId = useRef<number>(0);
|
||||||
const [messageList, setMessageList] = useState<MessageItem[]>([]);
|
const [messageList, setMessageList] = useState<
|
||||||
|
{
|
||||||
|
prompt: string;
|
||||||
|
voice: string;
|
||||||
|
format: string;
|
||||||
|
speed: number;
|
||||||
|
uid: number;
|
||||||
|
autoplay: boolean;
|
||||||
|
}[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@@ -78,51 +84,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const viewCodeMessage = useMemo(() => {
|
|
||||||
return generateMessages([
|
|
||||||
{ role: Roles.System, content: systemMessage },
|
|
||||||
...messageList
|
|
||||||
]);
|
|
||||||
}, [messageList, systemMessage]);
|
|
||||||
|
|
||||||
const setMessageId = () => {
|
const setMessageId = () => {
|
||||||
messageId.current = messageId.current + 1;
|
messageId.current = messageId.current + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNewMessage = (message?: { role: string; content: string }) => {
|
|
||||||
const newMessage = message || {
|
|
||||||
role:
|
|
||||||
_.last(messageList)?.role === Roles.User ? Roles.Assistant : Roles.User,
|
|
||||||
content: ''
|
|
||||||
};
|
|
||||||
messageList.push({
|
|
||||||
...newMessage,
|
|
||||||
uid: messageId.current + 1
|
|
||||||
});
|
|
||||||
setMessageId();
|
|
||||||
setMessageList([...messageList]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const joinMessage = (chunk: any) => {
|
|
||||||
setTokenResult({
|
|
||||||
...(chunk?.usage ?? {})
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!chunk || !_.get(chunk, 'choices', []).length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
contentRef.current =
|
|
||||||
contentRef.current + _.get(chunk, 'choices.0.delta.content', '');
|
|
||||||
setMessageList([
|
|
||||||
...messageList,
|
|
||||||
...currentMessageRef.current,
|
|
||||||
{
|
|
||||||
role: Roles.Assistant,
|
|
||||||
content: contentRef.current,
|
|
||||||
uid: messageId.current
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
const handleStopConversation = () => {
|
const handleStopConversation = () => {
|
||||||
controllerRef.current?.abort?.();
|
controllerRef.current?.abort?.();
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -134,39 +99,15 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
setMessageId();
|
setMessageId();
|
||||||
setTokenResult(null);
|
setTokenResult(null);
|
||||||
|
setCurrentPrompt(current?.content || '');
|
||||||
|
|
||||||
controllerRef.current?.abort?.();
|
controllerRef.current?.abort?.();
|
||||||
controllerRef.current = new AbortController();
|
controllerRef.current = new AbortController();
|
||||||
const signal = controllerRef.current.signal;
|
const signal = controllerRef.current.signal;
|
||||||
currentMessageRef.current = current
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
...current,
|
|
||||||
uid: messageId.current
|
|
||||||
}
|
|
||||||
]
|
|
||||||
: [];
|
|
||||||
|
|
||||||
contentRef.current = '';
|
|
||||||
setMessageList((pre) => {
|
|
||||||
return [...pre, ...currentMessageRef.current];
|
|
||||||
});
|
|
||||||
|
|
||||||
const messageParams = [
|
|
||||||
{ role: Roles.System, content: systemMessage },
|
|
||||||
...messageList,
|
|
||||||
...currentMessageRef.current
|
|
||||||
];
|
|
||||||
|
|
||||||
const messages = generateMessages(messageParams);
|
|
||||||
|
|
||||||
const chatParams = {
|
const chatParams = {
|
||||||
messages: messages,
|
|
||||||
...parameters,
|
...parameters,
|
||||||
stream: true,
|
prompt: current?.content || currentPrompt
|
||||||
stream_options: {
|
|
||||||
include_usage: true
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const result: any = await fetchChunkedData({
|
const result: any = await fetchChunkedData({
|
||||||
data: chatParams,
|
data: chatParams,
|
||||||
@@ -174,26 +115,16 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
signal
|
signal
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result?.error) {
|
setMessageList([
|
||||||
setTokenResult({
|
{
|
||||||
error: true,
|
prompt: current?.content || currentPrompt,
|
||||||
errorMessage:
|
voice: parameters.voice,
|
||||||
result?.data?.error?.message || result?.data?.message || ''
|
format: parameters.response_format,
|
||||||
});
|
speed: parameters.speed,
|
||||||
return;
|
uid: messageId.current,
|
||||||
}
|
autoplay: checkvalueRef.current
|
||||||
setMessageId();
|
|
||||||
const { reader, decoder } = result;
|
|
||||||
await readStreamData(reader, decoder, (chunk: any) => {
|
|
||||||
if (chunk?.error) {
|
|
||||||
setTokenResult({
|
|
||||||
error: true,
|
|
||||||
errorMessage: chunk?.error?.message || chunk?.message || ''
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
joinMessage(chunk);
|
]);
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.log('error:', error);
|
// console.log('error:', error);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -210,23 +141,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSendMessage = (message: Omit<MessageItem, 'uid'>) => {
|
const handleSendMessage = (message: Omit<MessageItem, 'uid'>) => {
|
||||||
// submitMessage(currentMessage);
|
submitMessage(message);
|
||||||
setMessageId();
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
setMessageList([
|
|
||||||
{
|
|
||||||
prompt: message.content,
|
|
||||||
voice: parameters.voice,
|
|
||||||
format: parameters.response_format,
|
|
||||||
speed: parameters.speed,
|
|
||||||
uid: messageId.current,
|
|
||||||
autoplay: checkvalueRef.current
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
setLoading(false);
|
|
||||||
}, 1000);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCloseViewCode = () => {
|
const handleCloseViewCode = () => {
|
||||||
@@ -236,7 +151,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const handleSelectModel = () => {};
|
const handleSelectModel = () => {};
|
||||||
|
|
||||||
const handleOnCheckChange = (e: any) => {
|
const handleOnCheckChange = (e: any) => {
|
||||||
console.log('handleOnCheckChange', e);
|
|
||||||
checkvalueRef.current = e.target.checked;
|
checkvalueRef.current = e.target.checked;
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -287,7 +201,11 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
className="font-size-32 text-secondary"
|
className="font-size-32 text-secondary"
|
||||||
></IconFont>
|
></IconFont>
|
||||||
</span>
|
</span>
|
||||||
<span>Generated speech will appear here</span>
|
<span>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: 'playground.audio.texttospeech.tips'
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{loading && (
|
{loading && (
|
||||||
@@ -314,7 +232,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
disabled={!parameters.model}
|
disabled={!parameters.model}
|
||||||
isEmpty={true}
|
isEmpty={true}
|
||||||
handleSubmit={handleSendMessage}
|
handleSubmit={handleSendMessage}
|
||||||
addMessage={handleNewMessage}
|
|
||||||
handleAbortFetch={handleStopConversation}
|
handleAbortFetch={handleStopConversation}
|
||||||
clearAll={handleClear}
|
clearAll={handleClear}
|
||||||
setModelSelections={handleSelectModel}
|
setModelSelections={handleSelectModel}
|
||||||
@@ -347,6 +264,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
payLoad={{
|
payLoad={{
|
||||||
prompt: currentPrompt
|
prompt: currentPrompt
|
||||||
}}
|
}}
|
||||||
|
api="audio/speech"
|
||||||
parameters={parameters}
|
parameters={parameters}
|
||||||
onCancel={handleCloseViewCode}
|
onCancel={handleCloseViewCode}
|
||||||
title={intl.formatMessage({ id: 'playground.viewcode' })}
|
title={intl.formatMessage({ id: 'playground.viewcode' })}
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ const Playground: React.FC = () => {
|
|||||||
const [loaded, setLoaded] = useState(false);
|
const [loaded, setLoaded] = useState(false);
|
||||||
const optionsList = [
|
const optionsList = [
|
||||||
{
|
{
|
||||||
label: 'Text To Speech',
|
label: intl.formatMessage({ id: 'playground.audio.texttospeech' }),
|
||||||
value: TabsValueMap.Tab1,
|
value: TabsValueMap.Tab1,
|
||||||
icon: <AudioOutlined />
|
icon: <AudioOutlined />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Speech To Text',
|
label: intl.formatMessage({ id: 'playground.audio.speechtotext' }),
|
||||||
value: TabsValueMap.Tab2,
|
value: TabsValueMap.Tab2,
|
||||||
icon: <IconFont type={'icon-audio'}></IconFont>
|
icon: <IconFont type={'icon-audio'}></IconFont>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export const fetchChunkedData = async (params: {
|
|||||||
...params.headers
|
...params.headers
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('response====', response);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return {
|
return {
|
||||||
error: true,
|
error: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user