//
//  VoiceModels.swift

//
//  Created by Leon on 2025/7/30.
//

import Foundation

class VoiceModel {

    
    var voiceDict:TimbreDict
    
    /// 音高
    var dialoguePitch: String = "0"
    /// 语速
    var dialogueSpeechRate: String = "25"
    
    var speechModel: SpeechModel?

    init(voiceDict: TimbreDict, speechModel: SpeechModel? = nil) {
        self.voiceDict = voiceDict
        
        if let pitchRate = voiceDict.pitchRate{
            dialoguePitch = "\(pitchRate)"
        }
        if let speechRate = voiceDict.speechRate{
            dialogueSpeechRate = "\(speechRate)"
        }
        
        if speechModel != nil{
            self.speechModel = speechModel
        }else if let url = voiceDict.url{
            self.speechModel = SpeechModel.modelWith(path: url)
        }
    }
    
    func syncConfigFrom(other: VoiceModel?){
        guard let otherVoice = other else{return}
        
        dialoguePitch = otherVoice.dialoguePitch
        dialogueSpeechRate = otherVoice.dialogueSpeechRate
//        voiceDict = otherVoice.voiceDict
//        speechModel = otherVoice.speechModel
    }
    
}
