To call Azure Marketplace Translation (and Speech) service

Dependencies:   EthernetInterface-FRDM HTTPClient-SSL R_BSP SDFileSystem TLV320_RBSP USBHost mbed-rtos mbed-src

The program calls Azure Marketplace Translation (and Speech) service.

How to use - Create an account for Microsoft Azure Marketplace - Get client ID and client secret. - Change client ID and client secret in main.cpp

The program was created based on the following libraries.

CodePlex Text-To-Speech with Microsoft Translator Service http://translatorservice.codeplex.com/

MBED HTTPClient-SSL Library https://developer.mbed.org/teams/MultiTech/code/HTTPClient-SSL/

/media/uploads/ksekimoto/gr-peach_cloud_speech_01.jpg

Committer:
ksekimoto
Date:
Sat Nov 07 12:29:06 2015 +0000
Revision:
1:a2bd45c3b373
Parent:
0:40a09c55e5be
To call Azure Marketplace Translation (and Speech) service.; The first version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ksekimoto 0:40a09c55e5be 1
ksekimoto 0:40a09c55e5be 2 #include <mbed.h>
ksekimoto 0:40a09c55e5be 3
ksekimoto 0:40a09c55e5be 4 int getline(char *prompt, char *buff, int size)
ksekimoto 0:40a09c55e5be 5 {
ksekimoto 0:40a09c55e5be 6 int sz ;
ksekimoto 0:40a09c55e5be 7
ksekimoto 0:40a09c55e5be 8 printf("%s", prompt) ;
ksekimoto 0:40a09c55e5be 9 for(sz = 0 ; (sz < size) && ((*buff = getchar()) != '\r'); sz++, buff++) {
ksekimoto 0:40a09c55e5be 10 putchar(*buff) ;
ksekimoto 0:40a09c55e5be 11 if(*buff == '\\') {
ksekimoto 0:40a09c55e5be 12 if(++sz >= size)break ;
ksekimoto 0:40a09c55e5be 13 *buff = getchar() ;
ksekimoto 0:40a09c55e5be 14 putchar(*buff) ;
ksekimoto 0:40a09c55e5be 15 switch(*buff) {
ksekimoto 0:40a09c55e5be 16 case 'n' :
ksekimoto 0:40a09c55e5be 17 *buff = '\n' ;
ksekimoto 0:40a09c55e5be 18 break ;
ksekimoto 0:40a09c55e5be 19 case 'r' :
ksekimoto 0:40a09c55e5be 20 *buff = '\r' ;
ksekimoto 0:40a09c55e5be 21 break ;
ksekimoto 0:40a09c55e5be 22 case 't' :
ksekimoto 0:40a09c55e5be 23 *buff = '\t' ;
ksekimoto 0:40a09c55e5be 24 break ;
ksekimoto 0:40a09c55e5be 25 case '\\':
ksekimoto 0:40a09c55e5be 26 *buff = '\\' ;
ksekimoto 0:40a09c55e5be 27 break ;
ksekimoto 0:40a09c55e5be 28 default:
ksekimoto 0:40a09c55e5be 29 buff[1] = buff[0] ;
ksekimoto 0:40a09c55e5be 30 buff[0] = '\\' ;
ksekimoto 0:40a09c55e5be 31 buff++ ;
ksekimoto 0:40a09c55e5be 32 }
ksekimoto 0:40a09c55e5be 33 } else if(*buff == '\b') {
ksekimoto 0:40a09c55e5be 34 if(sz >= 2) {
ksekimoto 0:40a09c55e5be 35 buff-=2 ;
ksekimoto 0:40a09c55e5be 36 sz-=2;
ksekimoto 0:40a09c55e5be 37 }
ksekimoto 0:40a09c55e5be 38 }
ksekimoto 0:40a09c55e5be 39 } ;
ksekimoto 0:40a09c55e5be 40 putchar('\n') ;
ksekimoto 0:40a09c55e5be 41 *buff = '\0' ;
ksekimoto 0:40a09c55e5be 42 return sz ;
ksekimoto 0:40a09c55e5be 43 }