import { Alova, url } from '../alova'

export const fetchTtsList = (num: string) => {
  return Alova.Get(url.ttsList, {
    params: {
      num
    }
  })
}

export interface SaveTOTTSParams {
  document: string
  voiceType: number
  speed: number
  volume: number
  num: string
}

export const saveTOTTS = (params: SaveTOTTSParams) => {
  return Alova.Post(url.ttsSave, {
    ...params,
    speed: String(params.speed),
    volume: String(params.volume),
    //
    voiceType: '101040'
  })
}

export const saveTOSTT = (params: { id?: string; num: string; file: File }) => {
  const forms = new FormData()
  forms.append('file', params.file)
  forms.append('num', params.num)
  params.id && forms.append('id', params.id)
  return Alova.Post(url.sttSave, forms)
}

export const deleteTTS = (params: { id: number; num: string }) => {
  return Alova.Post(url.ttsDel, {
    ...params
  })
}
