-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcode.py
More file actions
57 lines (38 loc) · 1.34 KB
/
code.py
File metadata and controls
57 lines (38 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-------------------------
import requests
def speak(text):
url = "http://localhost:5000/speak"
requests.get(url, data={"text": text})
-------------------------------------------
from flask import Flask, request, url_for, send_from_directory, jsonify
import os
app = Flask(__name__)
@app.route("/upload")
def upload():
img = request.files.get("image")
img.save(os.path.join("images", img.filename))
return jsonify({'url' : request.url_root[:-1] + url_for("get_image", name=img.filename)})
@app.route("/image/<name>")
def get_image(name):
return send_from_directory(os.path.join("images"), name)
if __name__ == "__main__":
app.run()
---------------------------------------------------------
from flask import Flask, request, jsonify
from gtts import gTTS
from playsound import playsound
import os
app = Flask(__name__)
def say(text):
tts = gTTS(text)
tts.save(os.path.dirname(os.path.realpath(__file__)) + "text.mp3")
playsound(os.path.dirname(os.path.realpath(__file__)) + "text.mp3")
os.remove(os.path.dirname(os.path.realpath(__file__)) + "text.mp3")
@app.route("/speak")
def speak():
text = request.values.get("text")
say(text)
return jsonify({"status": True})
if __name__ == "__main__":
app.run()
---------------------------------------------------------------