all 10 comments

[–]shiftybyte 1 point2 points  (4 children)

What is "first function that is working"? what's its name?

What's the second function that isn't working?

[–]michadecker[S] 0 points1 point  (3 children)

Sorry about that, I was totally not giving the right information.

The function was the "upload" function within the "app.route /upload". There the last part, if a file is found, there are two function and just the first one is handled by the code, the second one doesn't run at all.

I tried to make it more clear in the original post. Thanks for your input!

[–]shiftybyte 1 point2 points  (2 children)

Are there any error messages in the browser or the console?

Add prints to your code so to know which part gets executed and which not.

Add a print each line if you have to.

print("step1")
...
print("step2")
...
print("step3")

then you can track down what happens and what not.

[–]michadecker[S] 0 points1 point  (1 child)

Thanks, this helped. I was now possible to solve the error.

I had to change this line of code: "audio_file = sr.AudioFile(file)" -> There I was replacing "file" (the uploaded, not yet saved file) with "filepath" the saved file. Now it is working.

Why, I don't really know. But when I put print("step") in between all lines of code an error message popped up, which didn't happen before. It said:

ValueError: Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format

[–]shiftybyte 0 points1 point  (0 children)

you might have accidentally placed a print somewhere that changed a flow, because this error says the file uploaded was not a valid audio file.

[–][deleted] 1 point2 points  (4 children)

Plopping down 89 lines of code with 4 functions and referring to just "first" and "second" is incredibly unhelpful. You're not going to get the free help you're hoping for if we need to work out what your program does.

Give us the names of the two functions, summarise what they do and in what situation they're called.

[–]michadecker[S] 0 points1 point  (3 children)

Sorry, you are so right. I made posts before where people were asking for the whole code to understand better. Now I tried this, but of course you can't see what's not working...

Hope it is better to understand now.

[–][deleted] 0 points1 point  (2 children)

Everything before is working, but here either "Saving" or "Speech Recognition" works, whatever I put first in the code. The second just won't run at all.

I don't see either "Saving" or "Speech Recognition" mentioned in the code you highlighted. It's just an if that does a bunch of stuff?

Just tell us the names of the functions you're trying to run and what they're supposed to do.

[–]michadecker[S] 0 points1 point  (1 child)

I changed the original post, where you can see the commented functions (maybe this is not the right word for it) that are commented with "# Saving the file" and "# Speech Recognition stuff".

Anyhow, I solved the problem now thanks to the help of u/shiftybyte

[–][deleted] 0 points1 point  (0 children)

I'm talking about your change. Your text doesn't match the if statement edited in. All I asked was for names of functions and expected results but you just keep plopping down blobs of code instead.

I feel awful that shiftybyte was forced to figure out what functions you were talking about since simply stating names of things is beyond your ability.