Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: bad sample width #67

Open
HusainMkd opened this issue May 27, 2023 · 7 comments
Open

Error: bad sample width #67

HusainMkd opened this issue May 27, 2023 · 7 comments

Comments

@HusainMkd
Copy link

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
Copy link
Owner

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
Copy link
Author

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

@JonathanFly
Copy link
Owner

What OS are you on BTW?

@JonathanFly
Copy link
Owner

JonathanFly commented May 29, 2023

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
Copy link
Author

What OS are you on BTW?

I'm using Windows

@HusainMkd
Copy link
Author

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
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants