Defining routes

Now that we have the required dependencies, we will update the routes. To work with Cloud Speech API, we are going to add only one route that will accept a file, process it, and respond based on the response from Cloud Speech API. Update server/routes/cloud-ai-api.ts and add the upload-audio route, as shown here:

// SNIPP SNIPProuter.post('/upload-image/:threadId', Authenticate, Authorize('user'), upload.single('image-reply'), cloudAIAPI.uploadImage);router.post('/upload-video/:threadId', Authenticate, Authorize('user'), upload.single('video-reply'), cloudAIAPI.uploadVideo);router.post('/upload-audio/:threadId', Authenticate, Authorize('user'), upload.single('audio-reply'), cloudAIAPI.uploadAudio);// SNIPP SNIPP

Get Google Cloud AI Services Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.