Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View haruiz's full-sized avatar
🎓
Coding

Henry Ruiz, PhD haruiz

🎓
Coding
View GitHub Profile
#include "stdafx.h"
#include <Windows.h>
#include <NuiApi.h>
#include <opencv2/opencv.hpp>
int _tmain(int argc, _TCHAR* argv[])
{
cv::setUseOptimized( true );
var exec = require('child_process').exec;
var util = require("util");
var talk = (message, lang) =>{
lang = lang === "es" ? (' -l es-ES ') : (' -l en-US ');
const cmd = util.format("pico2wave -w speak.wav %s '%s' && sox speak.wav -r 48k speak.mp3 pitch -200 && omxplayer speak.mp3", lang, message)
console.log(cmd);
exec(cmd, function(error, stdout, stderr) {
if(error)
console.error(error);
const axios = require("axios");
module.exports = {
getToken : async(apikey)=>{
var config = {
headers: {'Ocp-Apim-Subscription-Key': apikey}
};
return axios.post("https://api.cognitive.microsoft.com/sts/v1.0/issueToken",{}, config);
}
}
{
"BING_SPEECH_API_KEY" : "<PUT YOUR BING SPEECH API>"//from https://www.microsoft.com/cognitive-services/en-US/subscriptions
}
@haruiz
haruiz / mymodule.cc
Last active May 11, 2017 00:06
basic native mocule node.js
#include <nan.h>
using namespace v8;
//definimos nuestra función (suma=>nombre)
NAN_METHOD(suma){
//validamos los parametros de entrada que le enviaremos desde js
if(!info[0]->IsNumber() && !info[2]->IsNumber() ){
//si los argumentos son invalidos arrojamos una exception
Nan::ThrowError("argumentos invalidos");
return;
from google.colab import drive
import os
def create_folder_gdrive(folder: str):
drive2mount = "/gdrive"
drive.mount(drive2mount, force_remount=True)
root_folder = os.path.join(drive2mount,"My Drive", folder)
os.makedirs(root_folder,exist_ok=True)
return root_folder
from google.colab import files
import cv2
import matplotlib.pyplot as plt
def upload(path):
uploaded = files.upload()
file_key = list(uploaded.keys())[0]
with open(path,"wb") as fp:
fp.write(uploaded[file_key])
# Install the PyDrive wrapper & import libraries.
# This only needs to be done once per notebook.
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
# Authenticate and create the PyDrive client.
# This only needs to be done once per notebook.
auth.authenticate_user()
//const robot = require("./Robot")("Cyg");
const hapi = require("hapi");
const boom = require("boom");
const path = require("path");
const ngrok = require('ngrok');
const bluebird = require("bluebird");
const fs = require("fs");
const Robot = require("./Robot");
const config = JSON.parse(fs.readFileSync("./config.json","utf8"));
/*para cargar el modulo nativo dentro de nuestro archivo js podemos
usar el pauqte bindings que instalamos al principio
o especificar la ruta completa de donde esta el archivo .node generado*/
//froma 1
const mymodule = require("bindings")("mymodule");//el .node no es necesario
//forma 2
//const mymodule = require("./build/Release/mymodule");//el .node no es necesario
const sum = mymodule.suma(2,2);
console.log("El resultado de la suma es :", sum);//mostramos el resultado