1 /** 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.car.voicecontrol; 17 18 import android.annotation.NonNull; 19 20 import java.util.List; 21 22 /** 23 * Minimal speech-to-text module interface. 24 */ 25 public interface SpeechToText { 26 /** 27 * Callbacks 28 */ 29 interface Listener { 30 /** 31 * Called when voice recognition is started 32 */ onRecognitionStarted()33 void onRecognitionStarted(); 34 35 /** 36 * Called when a partial result is detected. 37 */ onPartialRecognition(@onNull List<String> results)38 void onPartialRecognition(@NonNull List<String> results); 39 40 /** 41 * Called when recognition is finished. 42 * @param strings potential detected texts, or empty list if recognition was interrupted or 43 * unsuccessful. 44 */ onRecognitionFinished(@onNull List<String> results)45 void onRecognitionFinished(@NonNull List<String> results); 46 } 47 48 /** 49 * Starts recognition 50 */ startListening(Listener listener)51 void startListening(Listener listener); 52 53 /** 54 * Cancels recognition 55 */ stopListening()56 void stopListening(); 57 58 /** 59 * Releases internal resources 60 */ destroy()61 void destroy(); 62 } 63