mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 03:16:51 +08:00
Fix voice selection (#2664)
Co-authored-by: luowei <glpat-EjySCyNjWiLqAED-YmwM> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
This commit is contained in:
@@ -40,6 +40,7 @@ const TextToSpeech: FC = () => {
|
||||
{ languageInfo?.example && (
|
||||
<AudioBtn
|
||||
value={languageInfo?.example}
|
||||
voice={voiceItem?.value}
|
||||
isAudition={true}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -9,12 +9,14 @@ import { textToAudio } from '@/service/share'
|
||||
|
||||
type AudioBtnProps = {
|
||||
value: string
|
||||
voice?: string
|
||||
className?: string
|
||||
isAudition?: boolean
|
||||
}
|
||||
|
||||
const AudioBtn = ({
|
||||
value,
|
||||
voice,
|
||||
className,
|
||||
isAudition,
|
||||
}: AudioBtnProps) => {
|
||||
@@ -27,13 +29,16 @@ const AudioBtn = ({
|
||||
const pathname = usePathname()
|
||||
const removeCodeBlocks = (inputText: any) => {
|
||||
const codeBlockRegex = /```[\s\S]*?```/g
|
||||
return inputText.replace(codeBlockRegex, '')
|
||||
if (inputText)
|
||||
return inputText.replace(codeBlockRegex, '')
|
||||
return ''
|
||||
}
|
||||
|
||||
const playAudio = async () => {
|
||||
const formData = new FormData()
|
||||
if (value !== '') {
|
||||
formData.append('text', removeCodeBlocks(value))
|
||||
formData.append('voice', removeCodeBlocks(voice))
|
||||
|
||||
let url = ''
|
||||
let isPublic = false
|
||||
|
||||
@@ -77,6 +77,7 @@ const Operation: FC<OperationProps> = ({
|
||||
{(!isOpeningStatement && config?.text_to_speech?.enabled) && (
|
||||
<AudioBtn
|
||||
value={content}
|
||||
voice={config?.text_to_speech?.voice}
|
||||
className='hidden group-hover:block'
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user