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

Receiving error TypeError: 'float' object cannot be interpreted as an integer when trying to use sd.rec() constructor #564

Closed
288bb opened this issue Oct 10, 2024 · 2 comments · Fixed by #565

Comments

@288bb
Copy link

288bb commented Oct 10, 2024

Full log:

myrecording = sd.rec(dur, fs, 1)
  File "C:\Users\*bleep*\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\sounddevice.py", line 268, in rec
    out, ctx.frames = ctx.check_out(out, frames, channels, dtype, mapping)
  File "C:\Users\*bleep*\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\sounddevice.py", line 2547, in check_out
    out = np.empty((frames, channels), dtype, order='C')
TypeError: 'float' object cannot be interpreted as an integer
@mgeier
Copy link
Member

mgeier commented Oct 12, 2024

Thanks for reporting this!

Can you please show how dur and fs are defined?

It looks like they are (or one of them is) of type float, but only integer values are allowed for those parameters.

However, the error message could indeed be better, so I created #565.
Can you please check if that works for you?

@288bb
Copy link
Author

288bb commented Oct 14, 2024

That fixes it, also I found out the problem was that dur was not using integer division (//)

@288bb 288bb closed this as completed Oct 14, 2024
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

Successfully merging a pull request may close this issue.

2 participants