gpt4 book ai didi

ios - 使用 Gracenote SDK (GNSDK) 读取文件并执行指纹识别

转载 作者:行者123 更新时间:2023-11-28 21:32:15 30 4
gpt4 key购买 nike

我正在尝试从 iOS 上读取 16 位 16KHz wav(20 秒长)并执行指纹识别。我尝试按照指南“GNSDK-for-Mobile-iOS-Developers-Guide”进行操作,但它在第 53 页(仅 C#)上没有 objective-c 示例。我的代码读入整个文件,然后将 2K block 写入函数 fingerprintWrite(我也尝试过传递一个指向整个文件的指针)。变量“result”永远不会设置为 1 - 表示传递的数据不足 - 但 20 秒应该足够了,对吧?有人可以帮忙吗?谢谢。

这是我所做的:

    NSString *filepath = [[NSBundle mainBundle] pathForResource:@"Human.signed.20s.16bit" ofType:@"raw"];

NSData *audioData= [NSData dataWithContentsOfFile:filepath];

BOOL result;



if (error)

NSLog(@"Error reading file: %@", error.localizedDescription);



// for debugging...

NSLog(@"contents: %@", audioData);

NSLog(@"Done:");

unsigned char buffer[audioData.length];

[audioData getBytes:buffer length:audioData.length];

for (int i = 0; i < audioData.length; i++) {

printf("0x%02x ",(unsigned char)buffer[i]);

}



[self.gnMusicIDFileInfo fingerprintBegin:16000 audioSampleSize:16 audioChannels:1 error:&error];

if (error) {

NSLog(@"Error = %@", [error localizedDescription]);

}



int count = 0;

result = 0;

while (result==0 && count<sizeof(buffer)-2048)

{

result = [self.gnMusicIDFileInfo fingerprintWrite:&buffer[count] audioDataSize:2048 error:&error];

NSLog(@"Count = %i",count);

count=count+2048;

}



NSLog(@"result = %i", result);

if (error) {

NSLog(@"Error = %@", [error localizedDescription]);

}



[self.gnMusicIDFileInfo fingerprintEnd:&error];

if (error) {

NSLog(@"Error = %@", [error localizedDescription]);

}



[self.gnMusicIDFileInfo fingerprint:&error];

if (error) {

NSLog(@"Error = %@", [error localizedDescription]);

}

最佳答案

20 秒可能不够,因为识别过程需要足够数量的“可用”音频才能继续。另外,在做MusicID文件识别的时候,需要有歌曲开头的音频文件。如果您的用例只提供了歌曲的一部分并且歌曲没有从头开始,那么它很可能无法工作。您将需要改用 MusicID Stream。

关于ios - 使用 Gracenote SDK (GNSDK) 读取文件并执行指纹识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35436280/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com