As a guideline, to implement Baidu Cloud speech parsing with python3, you first need to simulate a Post request to drop the audio compressed file to Baidu for parsing.
But encountered a problem with the client how to throw the data are returned to the error, and then in the local django build an interface simulation, found that there is still a place to get it wrong!
What's the point of studying this stuff?
1, using python to do automated operation and maintenance, the client to send the collected information (simulate post send)
2, front-end and back-end separation, django only provides data, front-end with vuejs, nodejs to realize the
3. 3-terminal stereo communications
Previous code.
from import url from import admin from return_api import views urlpatterns = [ url(r'^api', ), ]
from import render from import JsonResponse # Create your views here. def apis(request): data={'name':'Your father'} # Data returned to the client if =="POST": print() #View the contents of the request from the client return JsonResponse(data) #pass (a bill or inspection etc) djangobuilt-inJsonspecification Throwing data to the client
import requests url = 'http://127.0.0.1:8001/api' #django api path parms = { 'name' : 'Client', # Content sent to the server } headers = { #The request header is browser normal, so it's been here all day! 'User-agent' : 'none/ofyourbusiness', 'Spam' : 'Eggs' } resp = (url, data=parms, headers=headers)# Send request # Decoded text returned by the request text = print((text))
Results:
Server-side:
Client:
That's about it. If you don't know what you're talking about, study the Baidu voice api and you'll be able to make a smart home or something.
Above this django implementation web interface python3 simulation Post request way is all I share with you, I hope to give you a reference, and I hope you support me more.