Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

[Android&iOS] Support language problem fix #33

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.3.2

- fixed android error

## 0.3.1

- fix android - Correcting problems that are not returned in the language you have called(SpeechRecognitionPlugin:68)
- fix exmaple code(main.dart:155)

## 0.3.0

- dart 2.0+ & Flutter 0.11.8
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public void onMethodCall(MethodCall call, Result result) {
result.success(true);
break;
case "speech.listen":
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, getLocale(call.arguments.toString()));
Log.d(LOG_TAG, "Listen Start, Language is "+call.arguments.toString());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, call.arguments.toString());
speech.startListening(recognizerIntent);
result.success(true);
break;
Expand All @@ -87,11 +88,6 @@ public void onMethodCall(MethodCall call, Result result) {
}
}

private Locale getLocale(String code) {
String[] localeParts = code.split("_");
return new Locale(localeParts[0], localeParts[1]);
}

@Override
public void onReadyForSpeech(Bundle params) {
Log.d(LOG_TAG, "onReadyForSpeech");
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 25
compileSdkVersion 28
buildToolsVersion '28.0.3'

lintOptions {
Expand Down
8 changes: 2 additions & 6 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
buildscript {
ext.kotlin_version = '1.2.71'
ext.kotlin_version = '1.3.10'
repositories {
google()
jcenter()

}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -29,7 +29,3 @@ subprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}
14 changes: 7 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ PODS:
- Flutter

DEPENDENCIES:
- Flutter (from `/Users/rxlabz/dev/tools/flutter/bin/cache/artifacts/engine/ios`)
- speech_recognition (from `/Users/rxlabz/dev/projects/_open/speech_recognition/ios`)
- Flutter (from `/Users/unryongpark/DevTools/flutter/bin/cache/artifacts/engine/ios`)
- speech_recognition (from `/Users/unryongpark/Development/speech_recognition/ios`)

EXTERNAL SOURCES:
Flutter:
:path: "/Users/rxlabz/dev/tools/flutter/bin/cache/artifacts/engine/ios"
:path: "/Users/unryongpark/DevTools/flutter/bin/cache/artifacts/engine/ios"
speech_recognition:
:path: "/Users/rxlabz/dev/projects/_open/speech_recognition/ios"
:path: "/Users/unryongpark/Development/speech_recognition/ios"

SPEC CHECKSUMS:
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
speech_recognition: acf2b916cd7aff5d4b76a238740afe2aff85e6bc
Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
speech_recognition: b5319aace06c3633c0547de44899f6e0bf8b2168

PODFILE CHECKSUM: cc70c01bca487bebd110b87397f017f3b76a89f1

COCOAPODS: 1.5.3
COCOAPODS: 1.6.1
21 changes: 11 additions & 10 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -39,7 +38,7 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
36CE85C39FAD16E17B4A50B4 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
Expand All @@ -54,6 +53,7 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A1DCAACEACECA470125741CD /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BF8D9B9E98039355C65504E9 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -73,6 +73,8 @@
04362A4B76DECA7982AB82AD /* Pods */ = {
isa = PBXGroup;
children = (
BF8D9B9E98039355C65504E9 /* Pods-Runner.debug.xcconfig */,
36CE85C39FAD16E17B4A50B4 /* Pods-Runner.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
Expand All @@ -82,7 +84,6 @@
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
Expand Down Expand Up @@ -177,7 +178,7 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 2P474ERK4G;
DevelopmentTeam = 7TYNC2SCRJ;
LastSwiftMigration = 1010;
};
};
Expand All @@ -187,6 +188,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand All @@ -207,7 +209,6 @@
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
Expand Down Expand Up @@ -236,8 +237,8 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../../../../../../tools/flutter/bin/cache/artifacts/engine/ios/Flutter.framework",
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../../../../../DevTools/flutter/bin/cache/artifacts/engine/ios/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/speech_recognition/speech_recognition.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -247,7 +248,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
77D16D5CA0547D170D81A685 /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -429,7 +430,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = 2P474ERK4G;
DEVELOPMENT_TEAM = 7TYNC2SCRJ;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -457,7 +458,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = 2P474ERK4G;
DEVELOPMENT_TEAM = 7TYNC2SCRJ;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
12 changes: 7 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ void main() {
}

const languages = const [
const Language('Francais', 'fr_FR'),
const Language('English', 'en_US'),
const Language('Francais', 'fr_FR'),
const Language('Pусский', 'ru_RU'),
const Language('Italiano', 'it_IT'),
const Language('Español', 'es_ES'),
const Language('Simplified Chinese', 'cmn-Hans-CN'),
const Language('Japanese', 'ja_JP'),
];

class Language {
Expand Down Expand Up @@ -128,9 +130,8 @@ class _MyAppState extends State<MyApp> {
),
));

void start() => _speech
.listen(locale: selectedLang.code)
.then((result) => print('_MyAppState.start => result $result'));
void start() => _speech.listen(locale: selectedLang.code).then((result) =>
print('_MyAppState.start => (' + selectedLang.code + ')result $result'));

void cancel() =>
_speech.cancel().then((result) => setState(() => _isListening = result));
Expand All @@ -152,7 +153,8 @@ class _MyAppState extends State<MyApp> {

void onRecognitionResult(String text) => setState(() => transcription = text);

void onRecognitionComplete() => setState(() => _isListening = false);
void onRecognitionComplete(String text) =>
setState(() => _isListening = false);

void errorHandler() => activateSpeechRecognizer();
}
2 changes: 1 addition & 1 deletion ios/Classes/SwiftSpeechRecognitionPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public class SwiftSpeechRecognitionPlugin: NSObject, FlutterPlugin, SFSpeechReco
case "es_ES":
return speechRecognizerEs
default:
return speechRecognizerFr
return SFSpeechRecognizer(locale: Locale(identifier: lang))!
}
}

Expand Down
2 changes: 1 addition & 1 deletion ios/speech_recognition.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ A new flutter plugin project.
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '10.0'
end

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: speech_recognition
description: A flutter plugin to use the speech recognition on iOS and Android
version: 0.3.0+1
version: 0.3.2
author: Erick Ghaumez <[email protected]>
homepage: https://github.com/rxlabz/speech_recognition
environment:
Expand Down