일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- google cloud
- 졸프
- idToken
- AWS
- react native
- google login
- pandas
- marksense.ai
- OG tag
- Loss Function
- 순환참조
- Spring Boot
- matplotlib
- @Transactional
- 코드업
- javascript
- yolo
- html
- JPA
- 2021 제9회 문화공공데이터 활용경진대회
- Expo
- Spring
- 양방향 매핑
- skt fellowship 3기
- STT
- oauth
- YOLOv5
- google 로그인
- C++
- 커스텀 데이터 학습
- Today
- Total
민팽로그
과제02-Google Cloud : Speech-to-Text API(1) 본문
Speech-to-Text
Google AI 기술로 지원되는 API를 사용하여 음성을 텍스트로 정확하게 변환
아래 사이트에서 사용방법 참고
https://cloud.google.com/speech-to-text?hl=ko
Speech-to-Text: 자동 음성 인식 | Google Cloud
쉽게 사용 가능한 API로 Google의 강력한 머신러닝 모델을 적용하여 125개 이상의 언어 및 방언으로 된 음성을 텍스트로 정확하게 변환할 수 있습니다.
cloud.google.com
클라이언트 라이브러리를 사용하여 JAVA로 음성인식 요청을 보내는 방법을 택했고 Eclipse와 Maven을 사용한다.
우선 간단한 사용환경 설정 과정은 아래와 같다.
1. Cloud Console 프로젝트를 설정
프로젝트를 만들거나 선택
프로젝트에 Cloud Speech-to-Text API를 사용 설정
서비스 계정 만들기
비공개 키를 JSON으로 다운로드
2. GOOGLE_APPLICATION_CREDENTIALS 환경변수 설정
eclipse에서 실행하려는 클래스 우클릭
Run as → Run Configurations 선택 → Environment 탭 → Add 클릭
Variable에 GOOGLE_APPLICATION_CREDENTIALS, Value에 JSON 경로 입력
3. Eclipse용 Cloud Tools 설치
Eclipse에서 Help(도움말) → Eclipse Marketplace 선택 → Eclipse용 Google Cloud Tools 검색 후 install
설치가 끝나면 이클립스 재시작
4. Add Library하여 Google Cloud Platform Libraries 추가
라이브러리 추가까지 완료한 후 아래 예제 코드를 그대로 돌려보았다.
// Imports the Google Cloud client library
import com.google.cloud.speech.v1.RecognitionAudio;
import com.google.cloud.speech.v1.RecognitionConfig;
import com.google.cloud.speech.v1.RecognitionConfig.AudioEncoding;
import com.google.cloud.speech.v1.RecognizeResponse;
import com.google.cloud.speech.v1.SpeechClient;
import com.google.cloud.speech.v1.SpeechRecognitionAlternative;
import com.google.cloud.speech.v1.SpeechRecognitionResult;
import com.google.protobuf.ByteString;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
public class QuickstartSample {
/** Demonstrates using the Speech API to transcribe an audio file. */
public static void main(String... args) throws Exception {
// Instantiates a client
try (SpeechClient speechClient = SpeechClient.create()) {
// The path to the audio file to transcribe
String gcsUri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw";
// Builds the sync recognize request
RecognitionConfig config =
RecognitionConfig.newBuilder()
.setEncoding(AudioEncoding.LINEAR16)
.setSampleRateHertz(16000)
.setLanguageCode("en-US")
.build();
RecognitionAudio audio = RecognitionAudio.newBuilder().setUri(gcsUri).build();
// Performs speech recognition on the audio file
RecognizeResponse response = speechClient.recognize(config, audio);
List<SpeechRecognitionResult> results = response.getResultsList();
for (SpeechRecognitionResult result : results) {
// There can be several alternative transcripts for a given chunk of speech. Just use the
// first (most likely) one here.
SpeechRecognitionAlternative alternative = result.getAlternativesList().get(0);
System.out.printf("Transcription: %s%n", alternative.getTranscript());
}
}
}
}
실행 결과 "Transcription: how old is the Brooklyn Bridge"가 나온다.
대시보드에서 요청이 제대로 들어가고 있는 것을 확인할 수 있다.
우리 프로젝트는 한국어 교육 어플이기 때문에 "한글 발화"를 텍스트로 바꿔야 하므로setLanguageCode에 줄 String 값으로 ko-KR을 사용하게 될 것이다.
음성 인식 방법에는 크게 아래의 세가지 방법이 있다.
1. 짧은 오디오 파일을 텍스트로 변환
2. 긴 오디오 파일을 텍스트로 변환
3. 스트리밍 입력의 오디오를 텍스트로 변환
1분 미만의 짧은 한글 오디오 파일을 텍스트로 변환하는것 부터 해봐야겠다.
그리고 사실
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
SLF4J Error Codes
SLF4J warning or error messages and their meanings No SLF4J providers were found. This warning, i.e. not an error, message is reported when no SLF4J providers could be found on the class path. Placing one (and only one) of slf4j-nop.jar slf4j-simple.jar, s
www.slf4j.org
라는 메세지가 콘솔창에 계속 나왔고 해결하려고 온갖 해결방법 포스팅을 보고 다 따라해봤는데..
시간만아깝다 결국 해결 안하기로^^!!
'프로젝트 > 소리마당(2022 프로보노)' 카테고리의 다른 글
공모전 참여 후기: 2021 제9회 문화공공데이터 활용경진대회 (0) | 2021.08.24 |
---|---|
2021.08.22 회의 느낀점 (0) | 2021.08.23 |
과제02-Google Cloud : Speech-to-Text API(4) (0) | 2021.08.20 |
과제02-Google Cloud : Speech-to-Text API(3) (0) | 2021.08.20 |
과제02-Google Cloud : Speech-to-Text API(2) (0) | 2021.08.20 |