diff --git a/public/uploads/1699015130374934.mp3 b/public/uploads/1699015130374934.mp3 new file mode 100644 index 0000000..e2ce14d Binary files /dev/null and b/public/uploads/1699015130374934.mp3 differ diff --git a/public/uploads/1699015830353839.mpeg b/public/uploads/1699015830353839.mpeg new file mode 100644 index 0000000..729b336 Binary files /dev/null and b/public/uploads/1699015830353839.mpeg differ diff --git a/routes/naturalLanguageRoute.js b/routes/naturalLanguageRoute.js index 246f797..39f3fed 100644 --- a/routes/naturalLanguageRoute.js +++ b/routes/naturalLanguageRoute.js @@ -5,9 +5,9 @@ const { audioUpload } = require("../utils") const { getSentiment, getAudioFromText, getTextFromAudio, getVoiceConfig, uploadAudioToTranscript, getJobStatus } = require('../controllers/naturalLanguageController') router.route('/sentiment').post(authorization, getSentiment) -router.route('/text-to-speech').get(getAudioFromText) -router.route('/speech-to-text').post(audioUpload.single('audio'), getTextFromAudio) -router.route('/upload-audio-to-transcript').post(audioUpload.single('audio'), uploadAudioToTranscript) +router.route('/text-to-speech').get(authorization, getAudioFromText) +router.route('/speech-to-text').post(audioUpload.single('audio'), authorization, getTextFromAudio) +router.route('/upload-audio-to-transcript').post(audioUpload.single('audio'), authorization, uploadAudioToTranscript) router.route('/query-job-status').get(getJobStatus) router.route('/voice-config').get(getVoiceConfig) diff --git a/swagger.yaml b/swagger.yaml index f5ce5ae..8e47865 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -1,30 +1,117 @@ openapi: 3.0.0 info: - title: Natural Language API + title: Natural Language API Google + description: This API describes the endpoints and parameters to use resources from Google Cloud API. contact: {} - description: This API describes the endpoints and parameters to use resources from google cloud api. version: '1.0' servers: -- url: http://localhost:6001/api/v1/nl/ +- url: http://localhost:6001/api/v1/nl variables: {} paths: + /upload-audio-to-transcript: + post: + tags: + - Speech to text async + summary: Speech to text job + operationId: Speechtotextjob + parameters: [] + requestBody: + content: + multipart/form-data: + encoding: {} + schema: + required: + - audio + type: object + properties: + audio: + type: string + format: binary + languageCode: + type: string + description: 'If not provided, the default will be: pt-BR' + example: pt-BR + required: false + responses: + '200': + description: '' + headers: {} + deprecated: false + security: + - bearer: [] + /query-job-status: + get: + tags: + - Speech to text async + summary: Speech to text job process + operationId: Speechtotextjobprocess + parameters: + - name: operationName + in: query + description: 'The job id returned after uploading the audio file that will be transcribed.' + required: true + style: form + explode: true + schema: + type: integer + format: int64 + example: 2993135803178989324 + responses: + '200': + description: '' + headers: {} + deprecated: false + security: + - bearer: [] + /speech-to-text: + post: + tags: + - Speech to text sync + summary: Speech to text + operationId: Speechtotext + parameters: [] + requestBody: + content: + multipart/form-data: + encoding: {} + schema: + required: + - audio + type: object + properties: + audio: + type: string + format: binary + languageCode: + description: 'If not provided, the default will be: pt-BR' + type: string + example: pt-BR + required: false + responses: + '200': + description: '' + headers: {} + deprecated: false + security: + - bearer: [] /sentiment: post: tags: - - API ROUTES + - Sentiment summary: Get sentiment operationId: Getsentiment parameters: [] requestBody: - description: 'The text that will be analyzed' + description: '' content: application/json: schema: - allOf: + allOf: + - $ref: '#/components/schemas/GetsentimentRequest' - example: - text: Vcs vao fica enrolando ate quando pra entregar isso! + text: Toda vez a mesma coisa ja to cansado de ficar ligando pra resolver esses problemas de conexão! example: - text: Vcs vao fica enrolando ate quando pra entregar isso! + text: Toda vez a mesma coisa ja to cansado de ficar ligando pra resolver esses problemas de conexão! required: true responses: '200': @@ -36,13 +123,13 @@ paths: /text-to-speech: get: tags: - - API ROUTES + - Text to speech summary: Text to speech operationId: Texttospeech parameters: - name: text in: query - description: 'The text that will be converted to audio' + description: '' required: true style: form explode: true @@ -51,31 +138,31 @@ paths: example: Vela branca na enxurrada la vou eu de léo em léo, se o navio é pequeno do tamanho de um chapeu, não importa a volta ao mundo, é viagem de brinquedo em um barquinho de papel. - name: voice_name in: query - description: 'The name of the voice. Ex: pt-BR-Wavenet-C' + description: '' required: false style: form explode: true schema: type: string - example: + example: pt-BR-Wavenet-C - name: voice_gender in: query - description: 'The name of the voice. Ex: FEMALE' + description: '' required: false style: form explode: true schema: type: string - example: + example: FEMALE - name: languageCode in: query - description: 'Ex pt-BR' + description: '' required: false style: form explode: true schema: type: string - example: + example: pt-BR responses: '200': description: '' @@ -86,13 +173,13 @@ paths: /voice-config: get: tags: - - API ROUTES + - Text to speech summary: Get voice config operationId: Getvoiceconfig parameters: - name: languageCode in: query - description: 'Ex pt-BR' + description: '' required: false style: form explode: true @@ -104,11 +191,26 @@ paths: description: '' headers: {} deprecated: false - security: - - bearer: [] -components: + security: [] +components: + schemas: + GetsentimentRequest: + title: GetsentimentRequest + required: + - text + type: object + properties: + text: + type: string + example: + text: Toda vez a mesma coisa ja to cansado de ficar ligando pra resolver esses problemas de conexão! securitySchemes: bearer: type: http scheme: bearer -security: [] \ No newline at end of file +security: [] +tags: +- name: Speech to text async +- name: Speech to text sync +- name: Sentiment +- name: Text to speech \ No newline at end of file diff --git a/swagger_production.yaml b/swagger_production.yaml new file mode 100644 index 0000000..93e639a --- /dev/null +++ b/swagger_production.yaml @@ -0,0 +1,216 @@ +openapi: 3.0.0 +info: + title: Natural Language API Google + description: This API describes the endpoints and parameters to use resources from Google Cloud API. + contact: {} + version: '1.0' +servers: +- url: https://hit-nl.omnihit.app.br/api/v1/nl + variables: {} +paths: + /upload-audio-to-transcript: + post: + tags: + - Speech to text async + summary: Speech to text job + operationId: Speechtotextjob + parameters: [] + requestBody: + content: + multipart/form-data: + encoding: {} + schema: + required: + - audio + type: object + properties: + audio: + type: string + format: binary + languageCode: + type: string + description: 'If not provided, the default will be: pt-BR' + example: pt-BR + required: false + responses: + '200': + description: '' + headers: {} + deprecated: false + security: + - bearer: [] + /query-job-status: + get: + tags: + - Speech to text async + summary: Speech to text job process + operationId: Speechtotextjobprocess + parameters: + - name: operationName + in: query + description: 'The job id returned after uploading the audio file that will be transcribed.' + required: true + style: form + explode: true + schema: + type: integer + format: int64 + example: 2993135803178989324 + responses: + '200': + description: '' + headers: {} + deprecated: false + security: + - bearer: [] + /speech-to-text: + post: + tags: + - Speech to text sync + summary: Speech to text + operationId: Speechtotext + parameters: [] + requestBody: + content: + multipart/form-data: + encoding: {} + schema: + required: + - audio + type: object + properties: + audio: + type: string + format: binary + languageCode: + description: 'If not provided, the default will be: pt-BR' + type: string + example: pt-BR + required: false + responses: + '200': + description: '' + headers: {} + deprecated: false + security: + - bearer: [] + /sentiment: + post: + tags: + - Sentiment + summary: Get sentiment + operationId: Getsentiment + parameters: [] + requestBody: + description: '' + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/GetsentimentRequest' + - example: + text: Toda vez a mesma coisa ja to cansado de ficar ligando pra resolver esses problemas de conexão! + example: + text: Toda vez a mesma coisa ja to cansado de ficar ligando pra resolver esses problemas de conexão! + required: true + responses: + '200': + description: '' + headers: {} + deprecated: false + security: + - bearer: [] + /text-to-speech: + get: + tags: + - Text to speech + summary: Text to speech + operationId: Texttospeech + parameters: + - name: text + in: query + description: '' + required: true + style: form + explode: true + schema: + type: string + example: Vela branca na enxurrada la vou eu de léo em léo, se o navio é pequeno do tamanho de um chapeu, não importa a volta ao mundo, é viagem de brinquedo em um barquinho de papel. + - name: voice_name + in: query + description: '' + required: false + style: form + explode: true + schema: + type: string + example: pt-BR-Wavenet-C + - name: voice_gender + in: query + description: '' + required: false + style: form + explode: true + schema: + type: string + example: FEMALE + - name: languageCode + in: query + description: '' + required: false + style: form + explode: true + schema: + type: string + example: pt-BR + responses: + '200': + description: '' + headers: {} + deprecated: false + security: + - bearer: [] + /voice-config: + get: + tags: + - Text to speech + summary: Get voice config + operationId: Getvoiceconfig + parameters: + - name: languageCode + in: query + description: '' + required: false + style: form + explode: true + schema: + type: string + example: pt-Br + responses: + '200': + description: '' + headers: {} + deprecated: false + security: [] +components: + schemas: + GetsentimentRequest: + title: GetsentimentRequest + required: + - text + type: object + properties: + text: + type: string + example: + text: Toda vez a mesma coisa ja to cansado de ficar ligando pra resolver esses problemas de conexão! + securitySchemes: + bearer: + type: http + scheme: bearer +security: [] +tags: +- name: Speech to text async +- name: Speech to text sync +- name: Sentiment +- name: Text to speech \ No newline at end of file