[go: nahoru, domu]

blob: e5dc2f42ac895373cccb397f7aa5ed3ebda4d5f6 [file] [log] [blame]
Avi Drissmand387f0922022-09-14 20:51:311// Copyright 2020 The Chromium Authors
evliu2e5dbee42020-04-09 23:35:292// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5module media.mojom;
6
Andrew Moylan961a47f22022-06-03 04:26:367import "media/mojo/mojom/audio_data.mojom";
Katie Dektar1ad8e7a2021-04-05 23:13:198import "media/mojo/mojom/audio_parameters.mojom";
Katie Dektarca90aaa52021-03-04 21:32:169import "media/mojo/mojom/audio_stream_factory.mojom";
evliu2e5dbee42020-04-09 23:35:2910import "media/mojo/mojom/media_types.mojom";
Andrew Moylanaad6265f2022-06-07 03:52:5611import "media/mojo/mojom/speech_recognition.mojom";
evliu14d897af2020-07-30 22:17:2112import "mojo/public/mojom/base/file_path.mojom";
Alex Gough810f5db22023-11-20 21:28:0413import "sandbox/policy/mojom/context.mojom";
Alex Gough9e8487c2021-08-19 05:26:3114import "sandbox/policy/mojom/sandbox.mojom";
evliu2e5dbee42020-04-09 23:35:2915
Andrew Moylan18aac032022-05-30 02:52:5816// Like a SpeechRecognitionContext, except it binds AudioSourceFetcher speech
17// recognizer objects, rather than SpeechRecognitionRecognizer objects. In
18// Chrome OS features like Dictation and Projector, every
19// OnDeviceSpeechRecognizer can own a
20// Remote<AudioSourceSpeechRecognitionContext>.
Alex Gough810f5db22023-11-20 21:28:0421[RequireContext=sandbox.mojom.Context.kBrowser]
Andrew Moylan18aac032022-05-30 02:52:5822interface AudioSourceSpeechRecognitionContext {
Katie Dektarca90aaa52021-03-04 21:32:1623 // Prepares microphone audio to be captured from within the
24 // SpeechRecognitionService process, with results passed back to the
25 // SpeechRecognitionRecognizerClient.
Alex Gough810f5db22023-11-20 21:28:0426 [AllowedContext=sandbox.mojom.Context.kBrowser]
Katie Dektarca90aaa52021-03-04 21:32:1627 BindAudioSourceFetcher(
Andrew Moylan18aac032022-05-30 02:52:5828 pending_receiver<AudioSourceFetcher> fetcher_receiver,
29 pending_remote<SpeechRecognitionRecognizerClient> client,
30 SpeechRecognitionOptions options)
31 => (bool is_multichannel_supported);
evliu2e5dbee42020-04-09 23:35:2932};
33
34// The main interface to a speech secognition service process.
35// Used by the browser to issue top-level control requests to the service,
36// acquired during process launch.
Alex Gough810f5db22023-11-20 21:28:0437[ServiceSandbox=sandbox.mojom.Sandbox.kSpeechRecognition,
38 RequireContext=sandbox.mojom.Context.kBrowser]
evliu2e5dbee42020-04-09 23:35:2939interface SpeechRecognitionService {
Andrew Moylan18aac032022-05-30 02:52:5840 // Binds a new SpeechRecognitionContext hosted in the service process.
41 BindSpeechRecognitionContext(
42 pending_receiver<SpeechRecognitionContext> context);
43
44 // Binds a new AudioSourceSpeechRecognitionContext hosted in the service
45 // process.
Alex Gough810f5db22023-11-20 21:28:0446 [AllowedContext=sandbox.mojom.Context.kBrowser]
Andrew Moylan18aac032022-05-30 02:52:5847 BindAudioSourceSpeechRecognitionContext(
48 pending_receiver<AudioSourceSpeechRecognitionContext> context);
evliu92468fa32020-06-08 21:05:5749
evliub8528322022-11-23 00:09:1450 // Sets the file path to the Speech On-Device API (SODA) binary, the config
51 // file paths for the language packs, and the primary language name.
52 SetSodaPaths(mojo_base.mojom.FilePath binary_path,
53 map<string, mojo_base.mojom.FilePath> config_paths,
54 string primary_language_name);
Abigail Klein644e5e62023-07-20 22:33:2555
56 // Sets various params to the Speech On-Device API (SODA) binary.
57 SetSodaParams(bool mask_offensive_words);
Evan Liu7932f462023-08-03 17:13:1258
59 // Sets the config file paths for the language packs. Used to notify the
60 // service when new language packs are installed.
61 SetSodaConfigPaths(map<string, mojo_base.mojom.FilePath> config_paths);
evliu92468fa32020-06-08 21:05:5762};
63
Katie Dektarca90aaa52021-03-04 21:32:1664// The interface used to start and stop fetching audio from the microphone
Alex Gough810f5db22023-11-20 21:28:0465// for speech recognition. Provided by the browser to the speech recognition
66// service.
67[RequireContext=sandbox.mojom.Context.kPrivilegedUtility]
Katie Dektarca90aaa52021-03-04 21:32:1668interface AudioSourceFetcher {
Katie Dektar92043392021-03-12 00:37:4469 // Begin fetching audio. Results will be returned using the
70 // Remote<SpeechRecognitionRecognizerClient> which was passed in
71 // BindAudioSourceFetcher.
Alex Gough810f5db22023-11-20 21:28:0472 [AllowedContext=sandbox.mojom.Context.kPrivilegedUtility]
Katie Dektar1ad8e7a2021-04-05 23:13:1973 Start(pending_remote<AudioStreamFactory> factory, string device_id,
74 media.mojom.AudioParameters audio_parameters);
Katie Dektar92043392021-03-12 00:37:4475
Katie Dektarca90aaa52021-03-04 21:32:1676 // Stops audio fetching.
77 Stop();
78};