MCPcopy Create free account
hub / github.com/NsLearning/LangHelper / do_POST

Method do_POST

LangHelper/main.py:130–260  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

128 self.send_header("Access-Control-Max-Age","86400")
129
130 def do_POST(self):
131 global playlist,pendinglist,SkipSpeaking,RecWorking,recorder,SttText,client,region_cnt,seaker_cnt,Specify_One_message,Specify_Speaker
132 global subprocess_number,iflytek_rec_appid,iflytek_rec_apikey,iflytek_assess_appid,iflytek_assess_appsecret,iflytek_assess_apikey,ss_assess_appkey,ss_assess_secretkey
133 global complete_init
134 if self.path == "/init":
135 content_length = int(self.headers['Content-Length'])
136 body = self.rfile.read(content_length)
137 data = json.loads(body.decode('utf-8'))
138 subprocess_number = int(data['subprocess_number'])
139
140 iflytek_rec_appid = data['iflytek_rec_appid']
141 iflytek_rec_apikey = data['iflytek_rec_apikey']
142 if client:
143 client.app_id = data['iflytek_rec_appid']
144 client.api_key= data['iflytek_rec_apikey']
145
146 iflytek_assess_appid = data['iflytek_assess_appid']
147 iflytek_assess_appsecret = data['iflytek_assess_appsecret']
148 iflytek_assess_apikey = data['iflytek_assess_apikey']
149 if assess:
150 assess.APPID = data['iflytek_assess_appid']
151 assess.APISecret = data['iflytek_assess_appsecret']
152 assess.APIKey = data['iflytek_assess_apikey']
153
154 ss_assess_appkey = data['ss_assess_appkey']
155 ss_assess_secretkey = data['ss_assess_secretkey']
156 if assess2:
157 assess2.appKey = data['ss_assess_appkey']
158 assess2.secretKey = data['ss_assess_secretkey']
159
160 response = {'message': 'setting init sucessfully',"data":""}
161 complete_init = True
162 elif self.path == "/play":
163 content_length = int(self.headers['Content-Length'])
164 body = self.rfile.read(content_length)
165 data = json.loads(body.decode('utf-8'))
166 text = data['text']
167 speaker = data['speaker']
168 response = {'message': 'ChatGPT said: '+text,"data":""}
169 text = TextIsSuitable(text)
170
171 now = datetime.datetime.now()
172 time_str = now.strftime("%H_%M_%S_%f")
173 file_path = "./Resource/read/"+ time_str +".wav"
174
175 if (len(playlist)) <=15 and (text.strip() != ''):
176 playlist.append([text,file_path,speaker])
177
178 elif self.path == "/Skip":
179 print("Skip command received")
180 SkipSpeaking = True
181 response = {'message': 'Skip command received !',"data":""}
182
183 elif self.path == "/Rec/Start":
184 print("Record start command received ")
185 content_length = int(self.headers['Content-Length'])
186 body = self.rfile.read(content_length)
187 data = json.loads(body.decode('utf-8'))

Callers

nothing calls this directly

Calls 8

TextIsSuitableFunction · 0.85
readMethod · 0.80
set_languageMethod · 0.80
runMethod · 0.80
main_logicMethod · 0.80
writeMethod · 0.80
get_finish_stateMethod · 0.45
start_connectionMethod · 0.45

Tested by

no test coverage detected