Creating the Audio API service

To get the supported languages and translate text, we are using Translate API service. Let's create this service now. Inside the client\app\services folder, create a file named translate.api.service.ts and update it as shown here:

// SNIPP SNIPPimport { Injectable } from '@angular/core';import { HttpClient } from '@angular/common/http';import { Observable } from 'rxjs/Observable';import { Message } from '../shared/models/message.model';@Injectable()export class TranslateAPIService { constructor(private http: HttpClient) {} getSupportedLanguages(): Observable < any > { return this.http.get < any > ('/api/supported-languages'); } translateText(message: Message, targetLang: String): Observable < Message > { return ...

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.