简体   繁体   中英

python export() got multiple values for argument 'format'

i have a wav file and i want to split according to the data i have in a list called speech and to export the the splitted wav files in folders according to the label variable

  label=speech[0]
  start= speech[1]
  end = speech[2] 
  newAudio = AudioSegment.from_wav(audio_file_path)
  newAudio = newAudio[start:end]
  if label==1:
    newAudio.export('/content/',x,'.wav', format="wav")
  else:
    newAudio.export('/content/',x,'.wav', format="wav")

but i keep getting the error export() got multiple values for argument 'format'

The function definition of export is as follows:

export(self, out_f=None, format='mp3', codec=None, bitrate=None, parameters=None, tags=None, id3v2_version='4', cover=None)

I think what you're trying to do with your first parameter is a string concatenation, eg change it to a f-string:

newAudio.export(f'/content/{x}.wav', format='wav')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM