2
我想使用Google雲語音API,因此我可以傳遞音頻文件並接收翻譯文本,但我堅持整合。我已經有API密鑰和所需的一切,但無法找到如何使用它從原生反應。在文檔中只有node.js的解釋(來自javascript部分)。還有幾個庫過期或只支持一個操作系統。有人成功了嗎?Google雲語音與React Native
從文檔Node.js的例子:
// Imports the Google Cloud client library
const Speech = require('@google-cloud/speech');
// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';
// Instantiates a client
const speechClient = Speech({
projectId: projectId
});
// The name of the audio file to transcribe
const fileName = './resources/audio.raw';
// The audio file's encoding and sample rate
const options = {
encoding: 'LINEAR16',
sampleRate: 16000
};
// Detects speech in the audio file
speechClient.recognize(fileName, options)
.then((results) => {
const transcription = results[0];
console.log(`Transcription: ${transcription}`);
});
你只需要開發自己的實現,爲Android和iOS創建本地模塊。 –