0.0.26 • Published 2 years ago
thoroughbred_react_native v0.0.26
thoroughbred_react_native
실시간 음성 인식 라이브러리 테스트 버전
Install
npm install thoroughbred_react_nativemethod
| name | type | description |
|---|---|---|
| connect() | method | 음성인식 서버와 연결하기 위해 사용 됩니다. 음성 녹음을 시작하기 전에 제일 먼저 호출해야 합니다. |
| start() | method | 음성 녹음을 시작할 때 호출합니다. 녹음이 시작됩니다. |
| end() | method | 음성 녹음을 종료할 때 호출합니다. 녹음이 종료됩니다. |
| disconnect() | method | 음성인식 서버와 연결을 종료할 때 호출합니다. 모든 작업이 완료되면 호출합니다. |
| onConnected | callback | 음성인식 서버와 연결이 완료됐을 때 호출할 콜백을 등록합니다. |
| onReady | callback | start() 호출 후 음성인식을 처리할 준비가 됐을 때 호출할 콜백을 등록합니다. |
| onResult | callback | 음성인식 결과를 처리할 콜백을 등록합니다. |
| onFinished | callback | end() 호출 후 음성인식이 완전히 종료됐을 때 호출할 콜백을 등록합니다. |
Example
import {ThoroughbredClient} from 'thoroughbred_react_native';
function App() {
const [result, setResult] = React.useState('');
// 객체가 중복으로 생성되는 것을 방지하기 위해 useRef를 사용하는 것을 권장합니다.
const thoroughbred = useRef(null);
if (!thoroughbred.current) {
thoroughbred.current = new ThoroughbredClient();
// 음성인식 서버와 연결이 완료됐을 때 호출할 콜백을 등록합니다.
thoroughbred.current.onConnected = () => {
// 이렇게 사용하면 연결되자마자 녹음을 시작할 수 있습니다.
thoroughbred.current.start();
};
// 음성인식 결과를 처리할 콜백을 등록합니다.
thoroughbred.current.onResult = result => {
setResult(result);
};
// start() 호출 후 음성인식을 처리할 준비가 됐을 때 호출할 콜백을 등록합니다.
thoroughbred.current.onReady = () => {
console.log('ready');
};
// end() 호출 후 음성인식이 완전히 종료됐을 때 호출할 콜백을 등록합니다.
thoroughbred.current.onFinished = () => {
console.log('finished');
};
}
return (
<SafeAreaView>
<Button
title={"connect"}
onPress={() => {
// 음성인식 서버와 연결합니다.
thoroughbred.current.connect();
}}
/>
<Button
title={'start'}
onPress={() => {
// 음성녹음을 시작합니다.
thoroughbred.current.start();
}}
/>
<Button
title={'end'}
onPress={() => {
// 음성녹음을 종료합니다.
thoroughbred.current.end();
}}
/>
<Button
title={'disconnect'}
onPress={async () => {
// 음성인식 서버와 연결을 종료합니다.
await thoroughbred.current.disconnect();
}}
/>
// 음성인식 결과를 출력합니다.
<Text>{result}</Text>
</SafeAreaView>
);
}References
0.0.26
2 years ago
0.0.25
2 years ago
0.0.24
2 years ago
0.0.23
2 years ago
0.0.22
2 years ago
0.0.21
2 years ago
0.0.20
2 years ago
0.0.19
2 years ago
0.0.18
2 years ago
0.0.17
2 years ago
0.0.16
2 years ago
0.0.15
2 years ago
0.0.14
2 years ago
0.0.13
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago