-1

my code:

enter def  play():
import pyo
s = pyo.Server()
s.boot()
s.start()
s.setInputDevice(4)
s.setOutputDevice(4)
p = input("path: ")
play_audio1 = pyo.SfPlayer(path=p, speed=[1.25, 1.25])
play_audio1.out()
s.gui(locals(), exit=False)
play()

code here so the problem im facing is, i want to take path as a user input and play the audio file. help me out. for now i have only tried taking it was a user input and storing it in a var and use it but it dosent work.

  • what does the error say? FileNotFound? – Michael Hsi Apr 13 '20 at 10:50
  • This is not a valid Python code: `SyntaxError: invalid syntax` – RMPR Apr 13 '20 at 10:54
  • @MichaelHsi play() File "C:\Users\dell\Desktop\test1.py", line 9, in play play_audio1 = pyo.SfPlayer(path=p, speed=[1.25, 1.25]) File "C:\Users\dell\Anaconda3\lib\site-packages\pyo\lib\players.py", line 112, in __init__ _snd_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(path[0]) TypeError: cannot unpack non-iterable NoneType object – aaditya Apr 13 '20 at 11:05
  • do a test run, before using pyo.SfPlayer, open your file using open(path, 'rb') and see if it throws FileNotFound – Michael Hsi Apr 13 '20 at 11:12

1 Answers1

0

Your code works fine for me. I have provided input from user as follows and i was able to get gui for audio.

path: C:/Users/anil/Downloads/M1F1-AlawC-AFsp.aif

If you are still facing issues. Kindly check below things.

p = p.replace('"','').replace("'","")

Note: Kindly try with '.aif' file. It should possibly work for you

anil kumar
  • 774
  • 7
  • 7
  • yes it worked, turns out the .aif file i used was corrupted – aaditya Apr 13 '20 at 12:26
  • @aaditya If the question is now irrelevant, please consider removing it. That way people won't try to solve it, or stumble upon it while looking for their own answer. – Keldorn Apr 18 '20 at 08:30