balibabu commited on
Commit
7b381b0
·
1 Parent(s): c058dac

feat: Supports text output and sound output #1877 (#2436)

Browse files

### What problem does this PR solve?

feat: Supports text output and sound output #1877

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

web/.umirc.ts CHANGED
@@ -36,12 +36,5 @@ export default defineConfig({
36
  logger: console,
37
  // pathRewrite: { '^/v1': '/v1' },
38
  },
39
- '/HPImageArchive': {
40
- target: 'https://cn.bing.com/',
41
- changeOrigin: true,
42
- ws: true,
43
- logger: console,
44
- // pathRewrite: { '^/v1': '/v1' },
45
- },
46
  },
47
  });
 
36
  logger: console,
37
  // pathRewrite: { '^/v1': '/v1' },
38
  },
 
 
 
 
 
 
 
39
  },
40
  });
web/src/components/message-item/hooks.ts CHANGED
@@ -3,6 +3,7 @@ import { useSetModalState } from '@/hooks/common-hooks';
3
  import { IRemoveMessageById, useSpeechWithSse } from '@/hooks/logic-hooks';
4
  import { IFeedbackRequestBody } from '@/interfaces/request/chat';
5
  import { getMessagePureId } from '@/utils/chat';
 
6
  import { SpeechPlayer } from 'openai-speech-stream-player';
7
  import { useCallback, useEffect, useRef, useState } from 'react';
8
 
@@ -94,14 +95,14 @@ export const useSpeech = (content: string, audioBinary?: string) => {
94
  }
95
  }, [setIsPlaying, speech, isPlaying, pause]);
96
 
97
- // useEffect(() => {
98
- // if (audioBinary) {
99
- // const units = hexStringToUint8Array(audioBinary);
100
- // if (units) {
101
- // player.current?.feed(units);
102
- // }
103
- // }
104
- // }, [audioBinary]);
105
 
106
  useEffect(() => {
107
  initialize();
 
3
  import { IRemoveMessageById, useSpeechWithSse } from '@/hooks/logic-hooks';
4
  import { IFeedbackRequestBody } from '@/interfaces/request/chat';
5
  import { getMessagePureId } from '@/utils/chat';
6
+ import { hexStringToUint8Array } from '@/utils/common-util';
7
  import { SpeechPlayer } from 'openai-speech-stream-player';
8
  import { useCallback, useEffect, useRef, useState } from 'react';
9
 
 
95
  }
96
  }, [setIsPlaying, speech, isPlaying, pause]);
97
 
98
+ useEffect(() => {
99
+ if (audioBinary) {
100
+ const units = hexStringToUint8Array(audioBinary);
101
+ if (units) {
102
+ player.current?.feed(units);
103
+ }
104
+ }
105
+ }, [audioBinary]);
106
 
107
  useEffect(() => {
108
  initialize();
web/src/locales/en.ts CHANGED
@@ -362,9 +362,9 @@ The above is the content you need to summarize.`,
362
  The 'knowledge' is a very special variable which will be filled-in with the retrieved chunks.
363
  All the variables in 'System' should be curly bracketed.`,
364
  add: 'Add',
365
- key: 'key',
366
  optional: 'Optional',
367
- operation: 'operation',
368
  model: 'Model',
369
  modelTip: 'Large language chat model',
370
  modelMessage: 'Please select!',
@@ -642,7 +642,7 @@ The above is the content you need to summarize.`,
642
  'Loop is the upper limit of the number of loops of the current component, when the number of loops exceeds the value of loop, it means that the component can not complete the current task, please re-optimize agent',
643
  yes: 'Yes',
644
  no: 'No',
645
- key: 'key',
646
  componentId: 'Component ID',
647
  add: 'Add',
648
  operation: 'operation',
 
362
  The 'knowledge' is a very special variable which will be filled-in with the retrieved chunks.
363
  All the variables in 'System' should be curly bracketed.`,
364
  add: 'Add',
365
+ key: 'Key',
366
  optional: 'Optional',
367
+ operation: 'Operation',
368
  model: 'Model',
369
  modelTip: 'Large language chat model',
370
  modelMessage: 'Please select!',
 
642
  'Loop is the upper limit of the number of loops of the current component, when the number of loops exceeds the value of loop, it means that the component can not complete the current task, please re-optimize agent',
643
  yes: 'Yes',
644
  no: 'No',
645
+ key: 'Key',
646
  componentId: 'Component ID',
647
  add: 'Add',
648
  operation: 'operation',
web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx CHANGED
@@ -99,7 +99,7 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
99
  >
100
  <Switch />
101
  </Form.Item> */}
102
- {/* <Form.Item
103
  label={t('tts')}
104
  valuePropName="checked"
105
  name={['prompt_config', 'tts']}
@@ -107,7 +107,7 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
107
  initialValue={false}
108
  >
109
  <Switch />
110
- </Form.Item> */}
111
  <KnowledgeBaseItem></KnowledgeBaseItem>
112
  </section>
113
  );
 
99
  >
100
  <Switch />
101
  </Form.Item> */}
102
+ <Form.Item
103
  label={t('tts')}
104
  valuePropName="checked"
105
  name={['prompt_config', 'tts']}
 
107
  initialValue={false}
108
  >
109
  <Switch />
110
+ </Form.Item>
111
  <KnowledgeBaseItem></KnowledgeBaseItem>
112
  </section>
113
  );