0

I'm using WAMP server and i have configured it to run python scripts and those scripts are executing but i was trying to run below script, this script is executing in windows terminal but when i try to execute it from browser with the help of wamp server then i'm getting this error :

Apache error log :

[Sat Nov 27 11:12:01.808031 2021] [cgi:error] [pid 6040:tid 1220] [client ::1:56483] End of script output before headers: test_nm.py

Apache access log :

::1 - - [27/Nov/2021:11:11:57 +0530] "-" 408 -
::1 - - [27/Nov/2021:11:12:01 +0530] "GET /test_nm.py HTTP/1.1" 500 653

Code

#!C:\Program Files\Python36\python.exe

print("Content-Type: text/html\n")

import numpy as np
import wave
from deepspeech import Model
from scipy.io import wavfile as wav
#import speech_recognition as sr

audio_file = "C:/deepspeechwk/audio/8455-210777-0068.wav"
ds = Model('C:/deepspeechwk/deepspeech-0.6.0-models/output_graph.pb',500)
ds.enableDecoderWithLM('C:/deepspeechwk/deepspeech-0.6.0-models/lm.binary','C:/deepspeechwk/deepspeech-0.6.0-models/trie', 0.75, 1.85)
rate, audio = wav.read(audio_file)
print(audio)
transcript =ds.stt(audio)
#print(transcript)

f = open("transcribe_text.txt", "a")
f.write(str(transcript))
f.close()

Screenshot :

enter image description here

Any solution to resolve this issue is highly appreciated, Thanks

user3653474
  • 3,393
  • 6
  • 49
  • 135
  • It seems that somehow printing the header is incorrect according to this: https://stackoverflow.com/a/22308061/7828101 . Does `print("Content-Type: text/html\n")` works for all your other python scripts? Does remove all but the imports give the same exception ? – manaclan Nov 27 '21 at 06:46
  • @manaclan: When i remove import then there is no error. print("Content-Type: text/html\n") is working in other scripts – user3653474 Nov 27 '21 at 06:54
  • you should try comment out each line to narrow down the problem and post it here. I can't help much as I don't have your code – manaclan Nov 27 '21 at 06:59
  • @manaclan In my question i have added the code – user3653474 Nov 27 '21 at 07:00
  • I mean, try comment all your code and then uncomment each line until the program break. Update the line that cause the program to break onto your question – manaclan Nov 27 '21 at 07:02
  • @manaclan when i remove these imports `import wave from deepspeech import Model from scipy.io import wavfile as wav` then there is no error, but i have to import these to run my code – user3653474 Nov 27 '21 at 07:06
  • did you install those library – manaclan Nov 27 '21 at 07:08
  • @manaclan yes i have installed these library and it is working when i run same program from the python terminal, issue is when i run in browser – user3653474 Nov 27 '21 at 07:09

0 Answers0