问题描述
当我从本地缓冲区加载文件时,它正在工作。但是当我使用GCS URI加载相同文件时,响应为null。
const fileName = './audio.wav';
// Reads a local audio file and converts it to base64
const file = fs.readFileSync(fileName);
const audioBytes = file.toString('base64');
const audio = {
uri: 'gs://bucket-name/path-to-audio/audio.wav'
// content: audioBytes
};
const config = {
audioChannelCount: 1,encoding: 'LINEAR16',sampleRateHertz: 16000,languageCode: 'ta-IN',};
const request = {
audio: audio,config: config,};
// Detects speech in the audio file
const [operation] = await client.longRunningRecognize(request);
console.info('OPERATION STATUS',operation.name);
当我尝试使用GCS URI加载它时,得到的响应为null。而当我尝试发送与缓冲区相同的文件时,我得到了正确的响应。
# from GCS
TRANSLATION STATUS true
OPERATION COMPLETE STATUS 3489419937829075659 null undefined
# from local file
TRANSLATION STATUS true
OPERATION COMPLETE STATUS 390578141483807025 வணக்கம் வணக்கம் வணக்கம் SpeechRecognitionResult {
alternatives: [
SpeechRecognitionAlternative {
words: [],transcript: 'வணக்கம் வணக்கம் வணக்கம்',confidence: 0.8997038006782532
}
]
}
当我创建一个操作名称为* 3489419937829075659的控制台*
STATUS DATA Operation {
_events: [Object: null prototype] {
newListener: [Function],removeListener: [Function]
},_eventsCount: 2,_maxListeners: undefined,completeListeners: 0,hasActiveListeners: false,latestResponse: {
name: '3489419937829075659',metadata: {
type_url: 'type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata',value: <Buffer 08 64 12 0c 08 d7 9e b7 fa 05 10 90 d6 a3 a5 02 1a 0c 08 dc 9e b7 fa 05 10 e0 b7 f0 c8 02 22 40 67 73 3a 2f 2f 73 74 61 67 69 6e 67 2e 63 65 72 74 69 ... 46 more bytes>
},done: true,response: {
type_url: 'type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeResponse',value: <Buffer >
},result: 'response'
},name: '3489419937829075659',error: undefined,longrunningDescriptor: LongRunningDescriptor {
operationsClient: OperationsClient {
auth: [GoogleAuth],innerApiCalls: [Object],descriptor: [Object]
},responseDecoder: [Function: bound decode_setup],metadataDecoder: [Function: bound decode_setup]
},result: LongRunningRecognizeResponse { results: [] },metadata: LongRunningRecognizeMetadata {
progressPercent: 100,startTime: Timestamp { seconds: [Long],nanos: 615050000 },lastUpdateTime: Timestamp { seconds: [Long],nanos: 689708000 }
},backoffSettings: {
initialRetryDelayMillis: 100,retryDelayMultiplier: 1.3,maxRetryDelayMillis: 60000,initialRpcTimeoutMillis: null,rpcTimeoutMultiplier: null,maxRpcTimeoutMillis: null,totalTimeoutMillis: null
},response: {
type_url: 'type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeResponse',value: <Buffer >
},_callOptions: undefined,[Symbol(kCapture)]: false
}
STATUS DATA undefined
对于操作,当我退出整个对象进行操作时,我得到了这个信息,
STATUS DATA Operation {
_events: [Object: null prototype] {
newListener: [Function],latestResponse: {
name: '390578141483807025',value: <Buffer 08 64 12 0c 08 f4 a3 b7 fa 05 10 88 e0 d4 ab 02 1a 0c 08 f7 a3 b7 fa 05 10 88 b0 ef d4 01>
},value: <Buffer 12 4a 0a 48 0a 41 e0 ae b5 e0 ae a3 e0 ae 95 e0 af 8d e0 ae 95 e0 ae ae e0 af 8d 20 e0 ae b5 e0 ae a3 e0 ae 95 e0 af 8d e0 ae 95 e0 ae ae e0 af 8d 20 ... 26 more bytes>
},name: '390578141483807025',result: LongRunningRecognizeResponse {
results: [ [SpeechRecognitionResult] ]
},nanos: 628437000 },nanos: 446421000 }
},value: <Buffer 12 4a 0a 48 0a 41 e0 ae b5 e0 ae a3 e0 ae 95 e0 af 8d e0 ae 95 e0 ae ae e0 af 8d 20 e0 ae b5 e0 ae a3 e0 ae 95 e0 af 8d e0 ae 95 e0 ae ae e0 af 8d 20 ... 26 more bytes>
},[Symbol(kCapture)]: false
}
STATUS DATA SpeechRecognitionResult {
alternatives: [
SpeechRecognitionAlternative {
words: [],confidence: 0.8997038006782532
}
]
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)