JonathanFly / bark

🚀 BARK INFINITY GUI CMD 🎶 Powered Up Bark Text-prompted Generative Audio Model
MIT License
994 stars 93 forks source link

Error: bad sample width #67

Open HusainMkd opened 1 year ago

HusainMkd commented 1 year ago

Hi! I'm coming across this error for a simple bit of Spanish translation (from a transcript):

Error                                     Traceback (most recent call last)

Error: bad sample width`

    355 
    354         self._sampwidth = sampwidth
--> 353             raise Error('bad sample width')
    352         if sampwidth < 1 or sampwidth > 4:
    351             raise Error('cannot change parameters after starting to write')
[/usr/lib/python3.10/wave.py](https://localhost:8080/#) in setsampwidth(self, sampwidth)

    892         # For some reason packing the wave header struct with
    891         wave_data.setframerate(self.frame_rate)
--> 890         wave_data.setsampwidth(self.sample_width)
    889         wave_data.setnchannels(self.channels)
    888         wave_data = wave.open(data, 'wb')
[/usr/local/lib/python3.10/dist-packages/pydub/audio_segment.py](https://localhost:8080/#) in export(self, out_f, format, codec, bitrate, parameters, tags, id3v2_version, cover)

    440                 audio.export(output_filepath, format=output_format)
    439             else:
--> 438                 audio.export(output_filepath, format="mp4", codec="aac")
    437             if output_format == 'mp4':
    436             audio = AudioSegment.from_wav(temp_wav)
[/content/bark/bark_infinity/api.py](https://localhost:8080/#) in write_audiofile(output_filepath, audio_arr, **kwargs)

    411 
    410 
--> 409         write_audiofile(filepath, audio_arr, **kwargs)
    408         filepath = generate_unique_filepath(filepath)
    407     if dry_run is not True:
[/content/bark/bark_infinity/api.py](https://localhost:8080/#) in write_seg_wav(filepath, audio_arr, **kwargs)

    362     hoarder_mode = kwargs.get('hoarder_mode', False)
    361 
--> 360         write_seg_wav(filepath, audio_arr, **kwargs)
    359     if audio_arr is not None and kwargs.get("segment_number", 1) != "base_history":
    358         write_seg_npz(filepath, full_generation, **kwargs)
[/content/bark/bark_infinity/api.py](https://localhost:8080/#) in write_one_segment(audio_arr, full_generation, **kwargs)

   1101 
   1100     print(f"Saved to {final_filename_will_be}")
-> 1099         write_one_segment(audio_arr = np.concatenate(audio_arr_segments), full_generation = full_generation_segments[0], **kwargs)
   1098     if not dry_run:
   1097     dry_run = kwargs.get('dry_run', None)
[/content/bark/bark_infinity/api.py](https://localhost:8080/#) in generate_audio_long(**kwargs)
5 frames

----> 1 api.generate_audio_long(text_prompt='La demo técnica que he visto, también es una.', history_prompt='/content/bark/bark/assets/prompts/es_speaker_5.npz')

[<ipython-input-18-75b96ee20956>](https://localhost:8080/#) in <cell line: 1>()
JonathanFly commented 1 year ago

I've never seen that. My guess is maybe it's the mp4 format, somehow it can't convert that file. It uses ffmpeg to convert I would try upgrading ffmpeg however you installed it. Windows. mamba upgrade ffmpeg etc. You can also switch to .mp3 or back to wav.

HusainMkd commented 1 year ago

Thanks! Will try & report back if I make any progress

JonathanFly commented 1 year ago

What OS are you on BTW?

JonathanFly commented 1 year ago

This should be fixed. Let me know if works.

git pull to update

As far I can tell you only got the error if you tried to add silence between segments. Or if you used the CLI, where I accidentally left it defaulting to adding 0.25 seconds of silence.

HusainMkd commented 1 year ago

What OS are you on BTW?

I'm using Windows

HusainMkd commented 1 year ago

This should be fixed. Let me know if works.

git pull to update

As far I can tell you only got the error if you tried to add silence between segments. Or if you used the CLI, where I accidentally left it defaulting to adding 0.25 seconds of silence.

Brilliant thanks, will do

HusainMkd commented 1 year ago

This should be fixed. Let me know if works.

git pull to update

As far I can tell you only got the error if you tried to add silence between segments. Or if you used the CLI, where I accidentally left it defaulting to adding 0.25 seconds of silence.

Seems to have worked - thank you!