我正在使用 Google Cast SDK 的 React Native 包装器,但无法从发送者向接收者发送消息。我可以投射媒体或暂停并恢复它。问题仅与自定义消息有关。我的自定义消息监听器永远不会在接收方被调用。该消息是否应该具有我所缺少的特定结构?提前致谢。
发件人:
GoogleCast.initChannel('urn:x-cast:testChannel');
GoogleCast.sendMessage('urn:x-cast:testChannel', 'testMessage');
Run Code Online (Sandbox Code Playgroud)
接收者:
const context = cast.framework.CastReceiverContext.getInstance();
const CUSTOM_CHANNEL = 'urn:x-cast:testChannel';
context.addCustomMessageListener(CUSTOM_CHANNEL, function(customEvent) {
// handle customEvent.
console.log('event received');
});
Run Code Online (Sandbox Code Playgroud)
编辑:我能够从接收者向发送者发送消息:
接收者:
context.sendCustomMessage(CUSTOM_CHANNEL , undefined, 'myMessage');
Run Code Online (Sandbox Code Playgroud)
发件人:
GoogleCast.EventEmitter.addListener(GoogleCast.CHANNEL_MESSAGE_RECEIVED, ({undefined, message}) => {
console.log(message);
});
Run Code Online (Sandbox Code Playgroud) 我有一个 .wav 文件,是我录制自己的声音并讲话了几分钟。假设我想找到我在音频中说“Mike”的确切时间。我研究了语音识别并使用 Google Speech API 进行了一些测试,但我得到的时间戳远不准确。
作为替代方案,我录制了一个非常短的 .wav 文件,我只是说“Mike”。我试图比较这两个 .wav 文件,并找到较长 .wav 文件中所说的“Mike”的每个时间戳。我发现了SleuthEye 的惊人答案
这段代码非常适合查找一个时间戳,但我不知道如何查找多个开始/结束时间:
import numpy as np
import sys
from scipy.io import wavfile
from scipy import signal
snippet = sys.argv[1]
source = sys.argv[2]
# read the sample to look for
rate_snippet, snippet = wavfile.read(snippet);
snippet = np.array(snippet, dtype='float')
# read the source
rate, source = wavfile.read(source);
source = np.array(source, dtype='float')
# resample such that both signals are at the same sampling rate (if required) …Run Code Online (Sandbox Code Playgroud)