Commit 9502ba91babbaa0bb3b4845e8ca473f17db4a377
1 parent
252c7e28
Exists in
master
and in
4 other branches
Remove tranlation step from video generation
Showing
6 changed files
with
21 additions
and
43 deletions
Show diff stats
core/renderer.py
... | ... | @@ -59,7 +59,7 @@ def start_video_creator(id): |
59 | 59 | """ |
60 | 60 | global display, ffmpeg |
61 | 61 | # logger.info("Starting video creator server") |
62 | - display = Display(visible=1, size=(800,600)) | |
62 | + display = Display(visible=0, size=(800,600)) | |
63 | 63 | display.start() |
64 | 64 | subprocess.call( |
65 | 65 | [ |
... | ... | @@ -202,7 +202,7 @@ def keep_alive(conn_send, conn_receive): |
202 | 202 | print("Renderer listening...") |
203 | 203 | while True: |
204 | 204 | try: |
205 | - manager.receive_from_queue("translations", run) | |
205 | + manager.receive_from_queue("glosses", run) | |
206 | 206 | except KeyboardInterrupt: |
207 | 207 | manager.close_connections() |
208 | 208 | os._exit(0) | ... | ... |
core/translator.py
... | ... | @@ -12,7 +12,6 @@ Author: Wesnydy Lima Ribeiro |
12 | 12 | E-Mail: wesnydy@lavid.ufpb.br |
13 | 13 | """ |
14 | 14 | |
15 | -import json | |
16 | 15 | import os |
17 | 16 | import pika |
18 | 17 | import PikaManager |
... | ... | @@ -38,18 +37,9 @@ def run(ch, method, properties, body): |
38 | 37 | body : string |
39 | 38 | Json string containing the necessary arguments for workers. |
40 | 39 | """ |
41 | - body = json.loads(body) | |
42 | 40 | print ("Translating...") |
43 | - try: | |
44 | - gloss = traduzir(body["text"].encode("utf8")) | |
45 | - if body["type"] == "gloss": | |
46 | - manager.send_to_queue("glosses", gloss, properties) | |
47 | - elif body["type"] == "video": | |
48 | - manager.send_to_queue("translations", gloss, properties) | |
49 | - else: | |
50 | - print("Unexpected type of request") | |
51 | - except KeyError: | |
52 | - print ("Can't find text") | |
41 | + gloss = traduzir(body) | |
42 | + manager.send_to_queue("translations", gloss, properties) | |
53 | 43 | print ("Ok") |
54 | 44 | |
55 | 45 | def keep_alive(conn_send, conn_receive): | ... | ... |
translate-api/bin/www
translate-api/controllers/translate.js
... | ... | @@ -12,33 +12,25 @@ var shortid = require('shortid') |
12 | 12 | , amqp = require('../helpers/amqpManager'); |
13 | 13 | |
14 | 14 | exports.translate = function(req, res) { |
15 | - | |
16 | - var body = {}; | |
17 | - var id = shortid.generate(); | |
18 | - | |
19 | 15 | if (!req.body.text) |
20 | 16 | return console.log('Text key is missing'); |
21 | 17 | |
22 | - body.text = req.body.text; | |
23 | - body.type = 'gloss'; | |
18 | + var id = shortid.generate(); | |
19 | + var text = req.body.text; | |
24 | 20 | |
25 | - amqp.sendToQueue(body, id,'texts', false, res); | |
26 | - amqp.sendToQueue(body, id,'logs', true, res); | |
27 | - amqp.receiveFromQueue(id, 'glosses', false, res); | |
21 | + amqp.sendToQueue(text, id,'texts', false, res); | |
22 | + amqp.sendToQueue(text, id,'logs', true, res); | |
23 | + amqp.receiveFromQueue(id, 'translations', false, res); | |
28 | 24 | }; |
29 | 25 | |
30 | 26 | exports.urltranslate = function(req, res) { |
31 | - | |
32 | - var body = {}; | |
33 | - var id = shortid.generate(); | |
34 | - | |
35 | 27 | if (!req.body.text) |
36 | 28 | return console.log('Text key missing'); |
37 | 29 | |
38 | - body.text = req.param('text').toString('utf8'); | |
39 | - body.type = 'gloss'; | |
30 | + var id = shortid.generate(); | |
31 | + var text = req.param('text').toString('utf8'); | |
40 | 32 | |
41 | - amqp.sendToQueue(body, id, 'texts', false, res); | |
42 | - amqp.sendToQueue(body, id, 'logs', true, res); | |
43 | - amqp.receiveFromQueue(id, 'glosses', false, res); | |
33 | + amqp.sendToQueue(text, id, 'texts', false, res); | |
34 | + amqp.sendToQueue(text, id, 'logs', true, res); | |
35 | + amqp.receiveFromQueue(id, 'translations', false, res); | |
44 | 36 | }; | ... | ... |
translate-api/controllers/video.js
... | ... | @@ -12,17 +12,13 @@ var shortid = require('shortid') |
12 | 12 | , amqp = require('../helpers/amqpManager'); |
13 | 13 | |
14 | 14 | exports.createVideo = function(req, res) { |
15 | + if (!req.body.gloss) | |
16 | + return console.log('Gloss key missing'); | |
15 | 17 | |
16 | - var body = {}; | |
17 | 18 | var id = shortid.generate(); |
19 | + var gloss = req.body.gloss; | |
18 | 20 | |
19 | - if (!req.body.text) | |
20 | - return console.log('Text key missing'); | |
21 | - | |
22 | - body.text = req.body.text; | |
23 | - body.type = 'video'; | |
24 | - | |
25 | - amqp.sendToQueue(body, id, 'texts', false, res); | |
26 | - amqp.sendToQueue(body, id, 'logs', true, res); | |
21 | + amqp.sendToQueue(gloss, id, 'glosses', false, res); | |
22 | + amqp.sendToQueue(gloss, id, 'logs', true, res); | |
27 | 23 | amqp.receiveFromQueue(id, 'videos', false, res); |
28 | 24 | }; | ... | ... |
translate-api/helpers/amqpManager.js
... | ... | @@ -26,7 +26,7 @@ exports.sendToQueue = function(body, id, queue, durability, res) { |
26 | 26 | throw err; |
27 | 27 | } |
28 | 28 | ch.assertQueue(queue, {durable : durability}); |
29 | - ch.sendToQueue(queue, new Buffer(JSON.stringify(body)), {correlationId : id}); | |
29 | + ch.sendToQueue(queue, new Buffer(body), {correlationId : id}); | |
30 | 30 | try { |
31 | 31 | ch.close(); |
32 | 32 | } | ... | ... |