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

Running errors and what I think are logical errors #3

Closed
mostcat opened this issue Mar 4, 2023 · 5 comments
Closed

Running errors and what I think are logical errors #3

mostcat opened this issue Mar 4, 2023 · 5 comments

Comments

@mostcat
Copy link

mostcat commented Mar 4, 2023

env:

  • Win10
  • Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 4 2021, 13:27:16) [MSC v.1928 64 bit (AMD64)] on win32

The error is concentrated in this sentence:

 stream.write(array.array('f',
                             ((volume * math.sin(2.0 * math.pi * i * tone[0] / float(sr)) + volume * math.sin(2.0 * math.pi * i * tone[1] / float(sr)))
                              for i in range(sr*int(length)))).tostring())

Error1:

stream.write(array.array('f',
AttributeError: 'array.array' object has no attribute 'tostring'

Error2:
sr*int(length))
int(length) = int(0.25) = 0


After fixing the above 2 errors, you can dial normally through the phone handset

    commandDTMF = array.array('f',((volume * math.sin(2.0 * math.pi * i * tone[0] / float(sr)) + volume * math.sin(2.0 * math.pi * i * tone[1] / float(sr)))
                                for i in range(int(sr*length)))).tobytes()
    stream.write(commandDTMF)
@zeyus
Copy link
Owner

zeyus commented Mar 4, 2023

Thanks @mostcat now that you've reported this I think what I will do is make a github workflow and add some tests for python 3.9-3.11, I originally wrote this I think it was just after python 3 came out and it was a learning project! But I'm really happy someone else uses it :D

I'll adress those fixes in a couple of days and hopefully make the whole thing a bit more robust. I can ping you on the pull request if you're interested in reviewing it!

@mostcat
Copy link
Author

mostcat commented Mar 5, 2023

I'm happy to be involved in maintaining
Your project has fewer external requirements and smaller installed libraries, so I like it.
Nowadays, there are very few people who can do DTMF, a very niche technology.
I am working on a Raspberry Pi application that connects to PSTN (ordinary telephone) as an amateur.

@zeyus
Copy link
Owner

zeyus commented Mar 5, 2023

Nice, I have a bunch of raspberry pis at home, they're awesome!

And yeah, DTMF is old, but so am I ;)

I've made a PR, it's still 100% WIP but basically the idea is that i will make a cli that is a bit more robust and compatible with the previous implementation (e.g. send a bunch of letters)
but on top of it, now it's modular so it can be loaded by another app easily with the bonus additions of

  • easy backend implementation (if you don't want to use pyaudio)
  • easy MF generator addition, you can create your own MF code -> frequency maps
  • tests will be added to make sure things work as they say they do
  • cli will accept pipe/stream input as well

currently I did the audio playback with a blocking implementation and started on a non-blocking implementation which might be useful but it should probably be done with asyncio rather than callbacks (it's just that pyaudio uses callbacks so i'll just start with that, it's probably enough, i think i might just add a simple queue implementation instead which the callback can read from until it runs out!)

you can see the in progress PR here: #4
feel free to comment / ask questions about it :)

@zeyus
Copy link
Owner

zeyus commented Mar 7, 2023

This should be pretty much done. There are some features that are partially implemented, but i'm happy to work on them if they're used, otherwise anyone is free to submit a PR with fixes, additions, tests, etc :)

let me know if you have any issues!!

@zeyus zeyus closed this as completed Mar 7, 2023
@mostcat
Copy link
Author

mostcat commented Mar 10, 2023

Your problem is fixed quickly, kudos to you.
I'm recently getting the whole landline dialing system working.
Currently using your DTMF base has been implemented, can achieve off-hook, voice DTMF dialing, play voice on Raspberry Pi 3, basically achieve the basic function of VMS (voice notification) I want, thank you for your contribution.
I will test your new code when I have time.

1fb233f648fdf37de09fc87f18fe840

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