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

AttributeError: 'PosixPath' object has no attribute 'write' #7

Open
mohammed-mostapha opened this issue Sep 19, 2021 · 1 comment
Open

Comments

@mohammed-mostapha
Copy link

as you stated in the readme file:
in the standalone dir, i used this code:

python spectrographic.py --image ./source.png --min_freq 10000 --max_freq 20000 --duration 10 --save sound.wav --play

and i am able to hear the output audio successfully, but after the audio playback finishes, i receive this error in terminal:

Traceback (most recent call last): File "spectrographic.py", line 457, in <module> run() File "spectrographic.py", line 453, in run main(sys.argv[1:]) File "spectrographic.py", line 447, in main sg.save(wav_file=args.save_file) File "spectrographic.py", line 173, in save wavio.write(wav_file, self.sound_array, self.SAMPLE_RATE) File "/home/mohamed/.local/lib/python3.8/site-packages/wavio.py", line 390, in write w.writeframes(wavdata) File "/usr/lib/python3.8/wave.py", line 438, in writeframes self.writeframesraw(data) File "/usr/lib/python3.8/wave.py", line 427, in writeframesraw self._ensure_header_written(len(data)) File "/usr/lib/python3.8/wave.py", line 468, in _ensure_header_written self._write_header(datasize) File "/usr/lib/python3.8/wave.py", line 472, in _write_header self._file.write(b'RIFF') AttributeError: 'PosixPath' object has no attribute 'write' Exception ignored in: <function Wave_write.__del__ at 0x7fd831e82820> Traceback (most recent call last): File "/usr/lib/python3.8/wave.py", line 327, in __del__ self.close() File "/usr/lib/python3.8/wave.py", line 445, in close self._ensure_header_written(0) File "/usr/lib/python3.8/wave.py", line 468, in _ensure_header_written self._write_header(datasize) File "/usr/lib/python3.8/wave.py", line 472, in _write_header self._file.write(b'RIFF') AttributeError: 'PosixPath' object has no attribute 'write'

@unreal79
Copy link

unreal79 commented Apr 8, 2022

Replace:

def parse_args(args):
...
    parser.add_argument(
        "-s",
        "--save",
        dest="save_file",
        help="Path to .wav file in which to save the SpectroGraphic.",
        action="store",
        default=Path("SoundGraphic.wav"),

to

        default="SoundGraphic.wav",

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