« first day (2948 days earlier)      last day (1997 days later) » 

12:37 AM
@johnsmith this room is doing its best not to look like a place for water cooler discussions anymore, so we'd like to keep it that way.
 
1:12 AM
Hello
oops
 
 
2 hours later…
3:01 AM
cabbage
 
 
4 hours later…
Im not the best with recursions
 
8:28 AM
@smci You mixed up j & i in the comment on that question.
 
 
2 hours later…
10:11 AM
Anyone knowledge about JSON RPC and python?
 
 
2 hours later…
11:44 AM
Hi all, does anybody know of a way I can make python automatically toggle a specific setting on windows 10. That specific setting being the Mobile Hotspot setting
 
user6718998
Hi. Why do I get error that 'can't convert complex to float' ? pastebin.com/FudfcP6q x and t are complex values, c is float
 
@Thewise I'd suggest by trying various individual elements of that big return statement to narrow down on what gives the error.
@SShah Maybe this can help (it's along the lines of...) reddit.com/r/learnpython/comments/4irf1n/…
@tijn167 It's better if you directly ask the question rather asking if anyone has any particular knowledge of that topic. See sopython.com/chatroom for more.
 
@shad0w_wa1k3r Thanks alot, ah man I have to make it edit the registry it seems, haha seems. Thanks, now the issue is, how do i determine, what registry item relates to the Mobile Hotspot setting
 
That's a windows question now, hopefully there will be something you can find via google.
I'd bet it also depends on the hardware support for mobile hotspots, but I think you're confident that it'd be present on the machine you'd run this code on.
 
Thanks and yeah I am confident the machine I want it to run on has it, and yeah googling as best I can now
 
11:57 AM
good luck
 
12:41 PM
@Thewise complex inside sin
Most implementations expect real angles
 
1:31 PM
@PM2Ring Aargh, thanks.
 
 
3 hours later…
4:24 PM
Cbg
I’m alive
 
4:42 PM
@Thewise use numpy.sin
or use proper math
>>> import numpy as np
>>> np.sin(1+2j)
(3.165778513216168+1.9596010414216063j)
>>> np.sin(1)*np.cosh(2) + 1j*np.cos(1)*np.sinh(2)
(3.165778513216168+1.9596010414216063j)
 
5:37 PM
HI,
 
hello
 
I am using speech_recognition library for speech to text conversion to make my personal assistant
speech_recognition library uses google api
What I want to do is, chatbot only responds when somebody calls its name
 
way too much code and way too broken formatting
please post your code in a code paste service
 
oh sure thanks. wait a sec
 
5:45 PM
https://paste.ofcode.org/pdb82zCx53PeJRcCsKhvis
faster one, which doesn't wait for its name being called
https://paste.ofcode.org/4MMNZtmDbAZ9rS82hxrDwm
slower version, which waits for its name being called
The only difference between them that following commands are executed twice in slower version, while in faster only once.
audio=r.listen(source)
command=r.recognize_google(audio)
The need to execute them twice is to fulfill the requirement that chatbot only responds to commands, when first called its name. Like google assistant and alexa do
In the faster version, these two commands are executed once in a loop, because its is always ready to execute commands, without waiting for its name being called
I want to make the slower version, fast. Somehow is it possible to have these two commands executed only once in a single function? and also it first listens to its name. and then listen to commands? like it is doing right now
 
thanks
 
why not just call r.listen once and then do if command.startswith('assistant'):?
 
woah thanks @Aran-Fey thanks for introducing me with a cool function. But It solves my problem partially. Although it will work only when I say assistant at the start of my command. But I want assistant to play a notification sound when I call its name, so that user may now that its now ready to listen to command. like google assistant and alexa do. After that I want to give command to assistant
 
then there's no way around calling listen and recognize_google twice.
 
do you have idea then how does google assistant and alexa manage to solve this problem?
 
5:57 PM
I guess they don't use an external API for speech recognition? dunno
 
Yes you are right. :-) It was my first experience in chat room. And I would love to come again here
 
you mean corticosteroid-binding globulin?
@Code-Apprentice
 
sure, if that's your thing
@NaufilMuhammad sopython.com/salad
 
Sure I didn't understand how does that answer my question. Sorry English is not my first language
 
6:06 PM
Hey just a quick question:
I've got a JSON response like {"1": 2}
How do I access the key fom my controller ?
 
we have our own language here and that's the dictionary for it
 
Well actually this is a Json but I can translate it to a dictionnary
 
@Baldráni what controller? Can you give more context by showing a complete code example? Be sure to use pastebin or gist and link here.
 
Pretty straight forward :
 
Are you familiar with the native json package in python? It will parse any json string directly into a python dict for you.
 
6:09 PM
        json_data = json.loads(request.body)
        cards = json_data['deck']
        for card in cards:
            #card = {1: 2} for exemple
            #how can I use 1 ?
 
Is card a string or a dict?
 
A dict I guess
 
card["1"]
^ if it's a dict, just as simple as this
 
Yeah but I can't know if its 1 or anything else
It a variable
 
Then look at the docs for dict
I think there's something like cards.keys().
Or you can even do for key in card: if you want to iterate over all of the keys.
 
6:10 PM
right ! Taht's what I'm looking for =)
 
I suggest you sharpen your googling skills...and familiarize yourself with python.org
the docs have all the answers for these types of questions.
 
Actually, start with a good python tutorial
 
Well I've got a bunch of tab open but since its returning me a JSON I was not looking for dict
 
that, too...what Andras said
when you do json.loads() you get a dict
it isn't json any more after that
 
key = list(card.keys())[0]
That is what I was looking for
How come is this suppose to be used
Sometimes I don't get Python
 
6:15 PM
hey again,
Please have a look at 4 to 5 line code here:
https://paste.ofcode.org/uKuc4gzE2dr6jJxB65Am4P
I want the code to keep listening to command=r.recognize_google(audio)
until given command starts with "assistant". How do I do that?
Since the above link is just a snippet. Full coding is here to grasp the full context:
https://paste.ofcode.org/Wpha8g7LFC3UdW2PLU7VE7
Thanks in advance.
Right now it just keeps going on in loops
sorry I got confused. lemme ask again
 
unrelated to your question, but don't put backslashes in paths in python. forward slashes work just fine on all systems, including windows (and if you do insist on using backslashes, mark the strings as r'raw strings')
 
@ThiefMaster Thanks for the suggesstion
I am updating the question.
 
Or if you want to use the platform's defined path separator, use os.path.join().
@Baldráni so you always want only the first key?
 
https://paste.ofcode.org/fqWw7VJr65ZPy5fv8PiiW
I want the code to keep listening to audio=r.listen(source) until given command starts with "assistant"
https://paste.ofcode.org/Wpha8g7LFC3UdW2PLU7VE7
Here is the full code to get the full context
 
What are the possible keys and what do they represent?
 
6:23 PM
Yup
        for card in cards:
            for key, value in card:
                for x in range(value):
                    key = list(card.keys())[0]
                    card = Card(id=key)
                    cardDeck = CardDeck(card=card, deck=deck)
                    cardDeck.save()
 
so, how do I do that? Right now, it keeps going on in loops when command doesnt start with "assistant" and results in playing of a notification sound, which signifies that command has been listened.
 
Cards is a JSON POST Value like [{1: 4}, {13: 5}]
 
Then key = list(card.keys())[0] is a no-op
 
@Baldráni What do the numbers mean?
 
Assuming that for key, value in card: is actually for key, value in card.items():
 
6:26 PM
@Baldráni note that you have two variables named key. As Aran-Fey says, you can fix the for loop and you don't need the assignment.
Or you can do something like this:
for key in card:
  value = card[key]
 
or key, value = card.popitem()
 
@Baldráni Do you have any control over the API you are sending the data to?
or the data that the API receives?
 
Look at my question please too. Its not complex
 
Yo whats up every one
 
I prefer data that is self-explanatory. For example, {"suit": "diamond", "value": "Ace", "count": 2} or something along these lines would be much more useable than just numbers.
@NiNisanNijackle Cabbage
@NaufilMuhammad I'm not familiar with voice recognition, so I don't think I can help.
 
6:32 PM
Sry I was out for a sec. So yeah I could change value sent by the API
Its a simple fetch.
And the first is hte id of the card obviously and the seccond is its quantity in the deck
 
I heard there was an open source library for the voice recognition.
It's not worth trying to do on your own unless if you are willing to dive into the complex math and adjust it to frequency patterens in voices.
 
oh alright @NiNisanNijackle So its not possible with speech_recognition api? I think my adjusting a while loop, we could do this?
by adjusting*
 
Oh I thought you were trying to make it from scratch lol
Link me @NaufilMuhammad so I can get the full context
 
I don't know about that API sorry...
 
6:37 PM
oh okay
 
I feel so good today. I just set up client and a server in different languages. C# (have to for Unity) and Python. YEET!!!!
 
@Baldráni "obviously"? I'm not sure how that is obvious from just looking at the JSON. If you do {"id": 1, "count": 5}, the meanings of the numbers will be more obvious. And there's an added benefit: you can get the values directly with card['id'] and card['count'] without needing any extra hoops to jump through.
 
card = Card(id=key)
 
but this requires that you have the ability to define how the API expects to send and receive its data.
@Baldráni now that's a problem...you are using the same variable name in two different ways.
for card in cards:
 
Yeahh I guess I'll change it
 
6:39 PM
Anyways, anyone here have experiance with setting up a TCP or UDP server? I have a quick question I need answered about best practices.
 
Ho I can't redefine it ?
 
what do you mean?
 
Im not used to python scope but I guess you can change variable pointer?
Well however I've changer the name for clarity
 
I suggest you do something like this: First, allow the JSON list to have the form [{"id": 1, "count": 5}, {"id": 2, "count": 3}]
cards = json.loads(request.body)
for card_data in cards:
  card = Card(id=card_data['id']
and you can use card_data['count'] to get the count.
 
Its far from easy to change data structure but I'll give a shot.
 
6:44 PM
Notice how much easier it is to write the code when you define the shape of the data in such a way.
 
Yes indeed
But the data was not meant to be used that way at first
 
of course, I only have a small window into the codebase, so I don't know how much this change would ripple through the rest of your code.
 
Its working side by side with an other dev that forced me to change my way of thinking.
I don't know either ^^
Will figure this out
Thank for your time anyway
 
@Baldráni, don't use numbers for json keys. it's a lot easier to iterate and debug with a constant in there.
Noone has experiance with setting up a udp or tcp server? Ok, I'll ask reddit.
 
wim
7:27 PM
sssafety firsst
 
 
1 hour later…
8:54 PM
Cbg
 
cbg
 
9:51 PM
Hi All, I am wondering if anybody has used pynput module before?, I was trying to make a script which automates the process of enabling mobile hotspot on windows 10, I couldnt find any direct solution, so decided to use this key input based method to get it to work. Please review the code here: paste.ofcode.org/8z3dzUmpYmFgZEavbPiBcN, for some reason, when I execute this code, the command 'keyboard.press(Key.right)', just doesnt seem to work for me.
Because this command doesnt work, its not doing what i want it to do.
As you can see i tried to add time.sleep as well, to see if that makes it work, but no luck
 
 
2 hours later…
11:43 PM
These solutions are a bit too advanced, I'm expected to use more basic code. Thank you though — Cheetaiean 52 mins ago
just another day on Stack Overflow
 

« first day (2948 days earlier)      last day (1997 days later) »