[Flutter] STT(Speach To Text) 예제 사용기. (feat. SDK 버전이슈)

huny·2023년 7월 26일
0

flutter

목록 보기
2/18
post-thumbnail

Flutter에서 STT(Speach To Text) 예제를 실행해보기 위해 아래의 링크로 이동하였다.

https://pub.dev/packages/speech_to_text/example

먼저 Install 을 진행하기 위해 Installing을 참고하였다.

이후 Example 에 있는 예제를 실행해보았다.
Android 폰을 연결하고 실행!

그리고 바로 나타나는 에러!

에러 전문을 붙여넣자면 다음과 같다.

┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────┐
│ The plugin speech_to_text requires a higher Android SDK version. │
│ Fix this issue by adding the following to the file │
│ C:\hun\util\flutter_project\stt_test\android\app\build.gradle: │
│ android { │
│ defaultConfig { │
│ minSdkVersion 21 │
│ } │
│ } │
│ │
│ Following this change, your app will not be available to users running Android SDKs below 21. │
│ Consider searching for a version of this plugin that supports these lower versions of the │
│ Android SDK instead. │
│ For more information, see: │
https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration
└───────────────────────────────────────────────────────────────────────────────────────────────┘

내용을 해석해보면 현재 사용하려는 STT 플러그인은 더 높은 SDK 버전을 요구한다고 한다.
그리고 이를 해결하기 위해서는 안내하는 경로로 가서 build.gradle 내부에 minSdkVersion. 즉 최소 버전을 명시하라고 되어있다.

해당 파일로 이동해서 다음과 같이 고쳐주었다.

이제 Build 를 해보면 아래와 같이 예제가 정상적으로 실행되는 것을 확인할 수 있다.
즉, 최소버전을 설정함으로써 해결할 수 있는 문제였다.

이후 실행을 하면 음성인식이 정상적으로 되지 않는 모습을 볼 수 있다.
왜냐면 권한을 주지 않았기 때문이다.

	<uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>

위 내용을 Android Menefest 파일에 기입해야한다.
<프로젝트루트경로>/android/app/src/main/AndroidManifest.xml
에 해당 파일이 있다.

아래와 같이 넣고 저장 후 다시 빌드해보면 정상 작동함을 볼 수 있다.

profile
재밌게 하고싶다.

0개의 댓글