Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于国区Apple Music里部分歌曲歌词识别有误 #20

Closed
stevewongv opened this issue Apr 15, 2017 · 7 comments
Closed

对于国区Apple Music里部分歌曲歌词识别有误 #20

stevewongv opened this issue Apr 15, 2017 · 7 comments

Comments

@stevewongv
Copy link

stevewongv commented Apr 15, 2017

国区Apple music中部分国外歌手的名字进行了中文翻译,所以导致搜索结果有偏差
比如https://itun.es/cn/2upzdb?i=1130689910
建议歌词搜索算法进行调整

@ddddxxx
Copy link
Owner

ddddxxx commented Apr 15, 2017

我不认为这是搜索算法的问题,没有算法能用错误的艺人搜索到正确的歌词。我们需要做的可能是:

  1. 判断从iTunes获取的艺人名字是否翻译过
  2. 用翻译的名字获取正确的名字
  3. 用正确的名字搜索

看起来有些困难,可能需要一份iTunes的翻译规则,有任何人有想法吗?

@stevewongv
Copy link
Author

获取这份iTunes翻译规则几乎是很难的,因为Apple music上的歌手随时会更新,无论是国区还是国外区(这里举个例子最近新上的好妹妹乐队,在国外区加Good meimei [此处黑人问好???]这与歌词库或者音乐站有所区别)不过不是每一首被改了歌手名的音乐都匹配不对哦。

我的建议是尝试用歌名、歌曲长度以及专辑名称来帮助匹配。

@ddddxxx
Copy link
Owner

ddddxxx commented Apr 17, 2017

无论如何,第一步识别是否翻译都是必要的。

我尝试根据文件大小来确认是否是Apple Music,根据是否包含中文字符来确认是否翻译。就结果来看基本正确。但由于没有开启iCloud音乐资料库,我只能测试流媒体的识别情况,我也没有测试中文艺人在国外区的翻译。

以下是测试代码,方法是在Playground中运行

import ScriptingBridge

extension String {
    var isHanzi: Bool {
        let threshold = 0.2
        let CJK = CharacterSet(charactersIn: "\u{4e00}"..."\u{9fff}")
        
        let count = characters.count
        let hanziCount = unicodeScalars.filter(CJK.contains).count
        
        guard count > 0 else { return false }
        return Double(hanziCount) / Double(count) > threshold
    }
}

func isAppleMusicStream() -> Bool {
    guard let iTunes = SBApplication(bundleIdentifier: "com.apple.iTunes"),
        let duration = iTunes.value(forKeyPath: "currentTrack.duration") as? Int,
        let size = iTunes.value(forKeyPath: "currentTrack.size") as? Int else {
        return false
    }
    return duration > 0 && size == 0
}

func isArtistBullshit() -> Bool {
    guard let iTunes = SBApplication(bundleIdentifier: "com.apple.iTunes"),
        let artist = iTunes.value(forKeyPath: "currentTrack.artist") as? String,
        let title = iTunes.value(forKeyPath: "currentTrack.name") as? String else {
            return false
    }
    
    return isAppleMusicStream() && artist.isHanzi != title.isHanzi
}

isAppleMusicStream()    // 判断是否为AppleMusic
isArtistBullshit()      // 判断艺人是否被翻译过

有条件的话,请帮忙测试一下以下情况:

  • 在线播放音乐
  • 播放离线缓存音乐
  • 英文艺人被翻译成中文
  • 中文艺人被翻译成英文
  • 中文艺人的英文歌曲可能被误判

@ddddxxx ddddxxx mentioned this issue Apr 29, 2017
@stevewongv
Copy link
Author

测试了段代码,效果不是特别理想。
离线/在线判断失败,我觉得这个并不需要
中文艺人的英文歌误判现象会出现,建议是把title换成album's title这样降低误判的可能性

@stevewongv
Copy link
Author

stevewongv commented May 6, 2017

误判其实可以根据歌曲的类别降低,一般中国的歌都是mandopop
202535211

@ddddxxx
Copy link
Owner

ddddxxx commented May 6, 2017

这样的话应该还包括jpop和kpop,不过我觉得意义不大。一些歌手本来就是英文名。

让程序判断这些实在有些强人所难,ID3信息本应是用户负责的。而且判断之后也不一定能找到正确的歌词(因为缺少了歌手信息)。
或许有折衷的方案,例如让用户自定义转换表。不过这样似乎不太优雅。

@ddddxxx
Copy link
Owner

ddddxxx commented May 2, 2018

国区 Apple Music 似乎不再翻译歌手名字,此问题不再有效。

@ddddxxx ddddxxx closed this as completed May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants