Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
- packages/tizen_package_manager/**/*
"p: tizen_rpc_port":
- packages/tizen_rpc_port/**/*
"p: tizen_stt":
- packages/tizen_stt/**/*
"p: tizen_window_manager":
- packages/tizen_window_manager/**/*
"p: url_launcher":
Expand Down
1 change: 1 addition & 0 deletions .github/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ plugins:
geolocator: []
in_app_purchase: []
network_info_plus: []
tizen_stt: []
video_player_avplay: []
video_player_videohole: []

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
| [**tizen_notification**](packages/tizen_notification) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_notification.svg)](https://pub.dev/packages/tizen_notification) | N/A |
| [**tizen_package_manager**](packages/tizen_package_manager) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_package_manager.svg)](https://pub.dev/packages/tizen_package_manager) | N/A |
| [**tizen_rpc_port**](packages/tizen_rpc_port) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_rpc_port.svg)](https://pub.dev/packages/tizen_rpc_port) | N/A |
| [**tizen_stt**](packages/tizen_stt) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_stt.svg)](https://pub.dev/packages/tizen_stt) | N/A |
| [**tizen_window_manager**](packages/tizen_window_manager) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/tizen_window_manager.svg)](https://pub.dev/packages/tizen_window_manager) | N/A |
| [**url_launcher_tizen**](packages/url_launcher) | [url_launcher](https://pub.dev/packages/url_launcher) (1st-party) | [![pub package](https://img.shields.io/pub/v/url_launcher_tizen.svg)](https://pub.dev/packages/url_launcher_tizen) | No |
| [**video_player_avplay**](packages/video_player_avplay) | (Tizen-only) | [![pub package](https://img.shields.io/pub/v/video_player_avplay.svg)](https://pub.dev/packages/video_player_avplay) | N/A |
Expand Down Expand Up @@ -85,6 +86,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
| [**tizen_notification**](packages/tizen_notification) | ✔️ | ✔️ | ❌ | API not supported |
| [**tizen_package_manager**](packages/tizen_package_manager) | ✔️ | ✔️ | ✔️ |
| [**tizen_rpc_port**](packages/tizen_rpc_port) | ✔️ | ✔️ | ✔️ |
| [**tizen_stt**](packages/tizen_stt) | ✔️ | ❌ | ❌ | Requires a supported microphone. |
| [**tizen_window_manager**](packages/tizen_window_manager) | ✔️ | ✔️ | ✔️ |
| [**url_launcher_tizen**](packages/url_launcher) | ✔️ | ❌ | ❌ | No browser app |
| [**video_player_avplay**](packages/video_player_avplay) | ✔️ | ❌ | ❌ | See README for details |
Expand Down
3 changes: 3 additions & 0 deletions packages/tizen_stt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.1.0

* Initial Tizen STT engine-recorder implementation.
25 changes: 25 additions & 0 deletions packages/tizen_stt/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2026 Samsung Electronics Co., Ltd. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the copyright holder nor the names of the
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 changes: 42 additions & 0 deletions packages/tizen_stt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# tizen_stt

Speech-to-text for Samsung TVs using the Tizen STT engine.

## Requirements

Requires a supported microphone.

Add the following to `tizen/tizen-manifest.xml`:

```xml
<privileges>
<privilege>http://tizen.org/privilege/recorder</privilege>
<privilege>http://tizen.org/privilege/internet</privilege>
</privileges>
<feature name="http://tizen.org/feature/microphone"/>
<feature name="http://tizen.org/feature/speech.recognition"/>
```

## Usage

```dart
import 'package:tizen_stt/tizen_stt.dart';

final stt = TizenStt();
final subscription = stt.events.listen((event) {
if (event.isPartialResult || event.isFinalResult) print(event.text);
if (event.isError) print(event.errorName ?? event.message);
});

await stt.initialize();
await stt.startListening();
// After the user speaks:
await stt.stopListening();
// After receiving the result, when finished:
await stt.dispose();
await subscription.cancel();
```

Use `getLanguages()` to select a language and `cancel()` to discard recognition.
All instances share one session. Handle `PlatformException` from control calls.
See the [example](example) for a complete app.
9 changes: 9 additions & 0 deletions packages/tizen_stt/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# tizen_stt_example

[![pub package](https://img.shields.io/pub/v/tizen_stt.svg)](https://pub.dev/packages/tizen_stt)

Demonstrates how to use the tizen_stt plugin.

## Getting Started

To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen).
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:tizen_stt/tizen_stt.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
final TizenStt stt = TizenStt();

setUp(() async {
expect(await stt.initialize(), TizenSttState.ready);
});

tearDown(() async {
await stt.dispose();
});

Future<void> expectTransition(
Future<TizenSttState> Function() action,
TizenSttState state,
) async {
final Future<void> event = stt.events
.timeout(const Duration(seconds: 10))
.firstWhere(
(TizenSttEvent event) => event.isError || event.state == state)
.then((TizenSttEvent event) =>
expect(event.state, state, reason: event.raw.toString()));
await Future.wait<Object?>(<Future<Object?>>[event, action()]);
}

test('languages and session disposal', () async {
expect(await stt.getLanguages(), isNotEmpty);
expect(await stt.getState(), TizenSttState.ready);
await stt.dispose();
expect(await stt.getState(), TizenSttState.notCreated);
});

test('recording can be cancelled', () async {
await expectTransition(stt.startListening, TizenSttState.recording);
await expectTransition(stt.cancel, TizenSttState.ready);
expect(await stt.getState(), TizenSttState.ready);
});

test('stopping recording starts processing', () async {
await expectTransition(stt.startListening, TizenSttState.recording);
await expectTransition(stt.stopListening, TizenSttState.processing);
});
}
209 changes: 209 additions & 0 deletions packages/tizen_stt/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
// Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:tizen_stt/tizen_stt.dart';

void main() => runApp(const MyApp());

/// Minimal STT test application.
class MyApp extends StatelessWidget {
/// Creates the example application.
const MyApp({super.key});

@override
Widget build(BuildContext context) => const MaterialApp(home: SttPage());
}

/// Exercises the native session lifecycle.
class SttPage extends StatefulWidget {
/// Creates the test page.
const SttPage({super.key});

@override
State<SttPage> createState() => _SttPageState();
}

class _SttPageState extends State<SttPage> with WidgetsBindingObserver {
final TizenStt _stt = TizenStt();
late final StreamSubscription<TizenSttEvent> _subscription;
TizenSttState _state = TizenSttState.notCreated;
bool _busy = false;
bool _partial = false;
List<String> _languages = <String>[];
String? _language;
String _text = '';
String _error = '';

@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
_subscription = _stt.events.listen((TizenSttEvent event) {
if (!mounted) {
return;
}
setState(() {
if (event.isStateChange) {
_state = event.state!;
}
if (event.isPartialResult || event.isFinalResult) {
_text = event.text ?? '';
}
if (event.isError) {
_error = event.errorName ?? event.message ?? 'Recognition failed';
}
});
}, onError: (Object error) {
if (mounted) {
setState(() => _error = error.toString());
}
});
}

Future<void> _run(Future<void> Function() action) async {
if (_busy) {
return;
}
setState(() {
_busy = true;
_error = '';
});
try {
await action();
} on PlatformException catch (error) {
if (mounted) {
setState(() => _error = '${error.code}: ${error.message ?? ''}');
}
} finally {
if (mounted) {
setState(() => _busy = false);
}
}
}

Future<void> _refresh() async {
final TizenSttState state = await _stt.getState();
if (mounted) {
setState(() => _state = state);
}
}

Future<void> _initialize() async {
await _stt.initialize();
final List<String> languages = await _stt.getLanguages();
if (mounted) {
setState(() {
_languages = languages;
_language = null;
});
}
await _refresh();
}

Future<void> _record() async {
if (_state == TizenSttState.recording) {
await _stt.stopListening();
} else {
setState(() => _text = '');
await _stt.startListening(
language: _language,
recognitionType: _partial
? TizenSttRecognitionType.freePartial
: TizenSttRecognitionType.free);
}
await _refresh();
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.paused) {
// Release the microphone even if a command is in flight.
unawaited(
_stt.dispose().then((_) => _refresh()).catchError((Object error) {
if (mounted) {
setState(() => _error = error.toString());
}
}));
}
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
unawaited(_subscription.cancel());
unawaited(
_stt.dispose().catchError((Object error) => debugPrint('$error')));
super.dispose();
}

@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Tizen STT')),
body: ListView(padding: const EdgeInsets.all(24), children: <Widget>[
Text('State: ${_state.name}', key: const Key('state')),
if (_busy) const Text('Working…'),
if (_error.isNotEmpty) Text(_error, key: const Key('error')),
Wrap(spacing: 12, children: <Widget>[
ElevatedButton(
autofocus: true,
onPressed: !_busy &&
(_state == TizenSttState.notCreated ||
_state == TizenSttState.created)
? () => _run(_initialize)
: null,
child: const Text('Initialize')),
ElevatedButton(
key: const Key('record_button'),
onPressed: !_busy &&
(_state == TizenSttState.ready ||
_state == TizenSttState.recording)
? () => _run(_record)
: null,
child: Text(
_state == TizenSttState.recording ? 'Stop' : 'Record')),
ElevatedButton(
onPressed: !_busy &&
(_state == TizenSttState.recording ||
_state == TizenSttState.processing)
? () => _run(() async {
await _stt.cancel();
await _refresh();
})
: null,
child: const Text('Cancel')),
ElevatedButton(
onPressed: !_busy && _state != TizenSttState.notCreated
? () => _run(() async {
await _stt.dispose();
await _refresh();
})
: null,
child: const Text('Dispose')),
]),
DropdownButton<String>(
value: _language,
hint: const Text('Automatic language'),
items: _languages
.map((String language) => DropdownMenuItem<String>(
value: language, child: Text(language)))
.toList(),
onChanged: !_busy && _state == TizenSttState.ready
? (String? value) => setState(() => _language = value)
: null),
CheckboxListTile(
title: const Text('Partial results (if supported)'),
value: _partial,
onChanged: !_busy && _state == TizenSttState.ready
? (bool? value) => setState(() => _partial = value!)
: null),
const SizedBox(height: 24),
SelectableText(
_text.isEmpty ? 'Recognized text appears here.' : _text),
]),
);
}
Loading
Loading