|
|
|
@ -1,9 +1,11 @@
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import styles from '@/components/FlowEditor/node/style/baseOther.module.less';
|
|
|
|
import styles from '@/components/FlowEditor/node/style/baseOther.module.less';
|
|
|
|
import { Handle, Position } from '@xyflow/react';
|
|
|
|
import { Handle, Position } from '@xyflow/react';
|
|
|
|
import { formatDataType } from '@/utils/common';
|
|
|
|
import { formatDataType } from '@/utils/common';
|
|
|
|
import { Button } from '@arco-design/web-react';
|
|
|
|
import { Button } from '@arco-design/web-react';
|
|
|
|
import { audioService } from '@/components/audio-recognize/audio/main';
|
|
|
|
import { audioService } from '@/components/audio-recognize/audio/main';
|
|
|
|
|
|
|
|
import { voiceTrigger } from '@/api/apps';
|
|
|
|
|
|
|
|
|
|
|
|
interface NodeContentData {
|
|
|
|
interface NodeContentData {
|
|
|
|
parameters?: {
|
|
|
|
parameters?: {
|
|
|
|
@ -187,6 +189,8 @@ const NodeContentMicrophone = ({ data }: { data: NodeContentData }) => {
|
|
|
|
const [isRecording, setIsRecording] = useState(false);
|
|
|
|
const [isRecording, setIsRecording] = useState(false);
|
|
|
|
const [resultText, setResultText] = useState('');
|
|
|
|
const [resultText, setResultText] = useState('');
|
|
|
|
const { connect, stop } = audioService(setResultText);
|
|
|
|
const { connect, stop } = audioService(setResultText);
|
|
|
|
|
|
|
|
const { appRuntimeData, currentAppData } = useSelector((state: any) => state.ideContainer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const apiIns = data.parameters?.apiIns || [];
|
|
|
|
const apiIns = data.parameters?.apiIns || [];
|
|
|
|
const apiOuts = data.parameters?.apiOuts || [];
|
|
|
|
const apiOuts = data.parameters?.apiOuts || [];
|
|
|
|
@ -217,8 +221,14 @@ const NodeContentMicrophone = ({ data }: { data: NodeContentData }) => {
|
|
|
|
const handleComplete = () => {
|
|
|
|
const handleComplete = () => {
|
|
|
|
console.log('用户结束语音转文字');
|
|
|
|
console.log('用户结束语音转文字');
|
|
|
|
stop();
|
|
|
|
stop();
|
|
|
|
// TODO 调接口 等待后端出接口
|
|
|
|
const params = {
|
|
|
|
// voiceTrigger(params);
|
|
|
|
nodeId: data.nodeId,
|
|
|
|
|
|
|
|
appId: currentAppData.id,
|
|
|
|
|
|
|
|
appInstanceId: appRuntimeData[currentAppData.id].runId,
|
|
|
|
|
|
|
|
msg: resultText || '你好'
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!params.msg || !params.nodeId) return;
|
|
|
|
|
|
|
|
voiceTrigger(params);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
@ -287,6 +297,28 @@ const NodeContentMicrophone = ({ data }: { data: NodeContentData }) => {
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className={styles['node-content-box']}>
|
|
|
|
|
|
|
|
<textarea
|
|
|
|
|
|
|
|
value={resultText}
|
|
|
|
|
|
|
|
placeholder="等待语音输入..."
|
|
|
|
|
|
|
|
readOnly
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
height: '80px',
|
|
|
|
|
|
|
|
padding: '8px',
|
|
|
|
|
|
|
|
backgroundColor: '#f7f8fa',
|
|
|
|
|
|
|
|
borderRadius: '4px',
|
|
|
|
|
|
|
|
fontSize: '12px',
|
|
|
|
|
|
|
|
lineHeight: '1.5',
|
|
|
|
|
|
|
|
color: '#4e5969',
|
|
|
|
|
|
|
|
border: '1px solid #e5e6eb',
|
|
|
|
|
|
|
|
resize: 'none',
|
|
|
|
|
|
|
|
outline: 'none',
|
|
|
|
|
|
|
|
fontFamily: 'inherit'
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/*footer栏*/}
|
|
|
|
{/*footer栏*/}
|
|
|
|
<div className={styles['node-footer']}>
|
|
|
|
<div className={styles['node-footer']}>
|
|
|
|
{!isRecording ?
|
|
|
|
{!isRecording ?
|
|
|
|
|