fix: 修复SpeechGenerationModal中emotion字段的TypeScript类型错误
- 为emotion字段添加类型断言,确保e.target.value符合SpeechGenerationRequest接口的emotion联合类型要求 - 解决了'string'类型无法分配给emotion联合类型的编译错误
This commit is contained in:
parent
f246850cb9
commit
b2c6aac3e9
|
|
@ -1,14 +1,12 @@
|
||||||
import React, { useState, useCallback, useEffect } from 'react';
|
import React, { useState, useCallback } from 'react';
|
||||||
import {
|
import {
|
||||||
Volume2,
|
Volume2,
|
||||||
Play,
|
|
||||||
Download,
|
Download,
|
||||||
CheckCircle,
|
CheckCircle,
|
||||||
XCircle,
|
XCircle,
|
||||||
Loader2,
|
Loader2,
|
||||||
Settings,
|
Settings,
|
||||||
Users,
|
Users,
|
||||||
Mic,
|
|
||||||
ChevronDown
|
ChevronDown
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
|
@ -21,7 +19,6 @@ import {
|
||||||
SpeechGenerationStatus,
|
SpeechGenerationStatus,
|
||||||
SpeechGenerationState,
|
SpeechGenerationState,
|
||||||
VoiceInfo,
|
VoiceInfo,
|
||||||
GetVoicesResponse
|
|
||||||
} from '../types/voiceClone';
|
} from '../types/voiceClone';
|
||||||
import { SystemVoice } from '../types/systemVoice';
|
import { SystemVoice } from '../types/systemVoice';
|
||||||
|
|
||||||
|
|
@ -68,7 +65,7 @@ export const SpeechGenerationModal: React.FC<SpeechGenerationModalProps> = ({
|
||||||
// ============= 音色选择功能 =============
|
// ============= 音色选择功能 =============
|
||||||
|
|
||||||
const handleVoiceSelect = useCallback((voiceId: string, voiceInfo: VoiceInfo | SystemVoice, source: 'system' | 'custom') => {
|
const handleVoiceSelect = useCallback((voiceId: string, voiceInfo: VoiceInfo | SystemVoice, source: 'system' | 'custom') => {
|
||||||
const voiceName = 'voice_name' in voiceInfo ? voiceInfo.voice_name : voiceInfo.name;
|
const voiceName = voiceInfo.voice_name;
|
||||||
|
|
||||||
setSelectedVoice({
|
setSelectedVoice({
|
||||||
id: voiceId,
|
id: voiceId,
|
||||||
|
|
@ -292,7 +289,7 @@ export const SpeechGenerationModal: React.FC<SpeechGenerationModalProps> = ({
|
||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
value={speechRequest.emotion || 'calm'}
|
value={speechRequest.emotion || 'calm'}
|
||||||
onChange={(e) => setSpeechRequest(prev => ({ ...prev, emotion: e.target.value }))}
|
onChange={(e) => setSpeechRequest(prev => ({ ...prev, emotion: e.target.value as 'happy' | 'sad' | 'angry' | 'fearful' | 'disgusted' | 'surprised' | 'calm' }))}
|
||||||
disabled={speechState.status === SpeechGenerationStatus.GENERATING}
|
disabled={speechState.status === SpeechGenerationStatus.GENERATING}
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue