What to do with "Cannot specify extra characters after a string enclosed in quotation marks" error?

Question:

I have a piece of code that plays a sound using the playsound module but the file location gives an error:

import playsound

playsound.playsound('C:\Users\nc_ma\Downloads\Note1.mp3')

error:

Error 305 for command:
    open "C:Usersnc_maDownloadsNote1.mp3"
Cannot specify extra characters after a string enclosed in quotation marks.

Answers:

I had the same problem and I tried another way:
I used os

import os
os.startfile('path\file.filetype')

and it started working
for you:

os.startfile('C:\Users\nc_ma\Downloads\Note1.mp3')

or

from playsound import playsound
playsound('Path\File Name.mp3')
Answered By: Akitoo

I was having a similar issue of Error 305 . Check your playsound version. There is an issue with version 1.3. Downgrading to version 1.2.2 worked for me.

Follow the below steps:

pip uninstall playsound
pip install playsound==1.2.2

Run the same file again. It should work.

Answered By: Anirvana

The python package playsound is effectively broken. I made a replacement here:

https://github.com/zackees/playaudio

Which can be installed via:

pip install playaudio

Keep in mind this is a blocking library. So you’ll need to wrap it in a thread if you want to want async behavior.

Answered By: Zachary Vorhies
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.