编辑并添加mp3的ID3标签

时间:2018-08-23 17:29:31

标签: mp3 text-to-speech

我正在通过gTTS(Google文本到语音)创建mp3文件,这是一个Python库和CLI工具,可与Google Translate的文本到语音API交互。如何将图像添加到mp3文件。谢谢

from mp3_tagger import MP3File, VERSION_1, VERSION_2, VERSION_BOTH
from gtts import gTTS
start = "Hello,this is  Alice ."
greetings ="That is the end of the news for today.  Have a good day. "
final_news = start + greetings
tts = gTTS(text=final_news, lang='en')
tts.save("news1.mp3") 
# Create MP3File instance.
mp3 = MP3File('news1.mp3')
# Get all tags.
tags = mp3.get_tags()
print tags

输出如下: { 'ID3TagV1':{ '专辑':u'UUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ' '评论':u'UUUUUUUUUUUUUUUUUUUUUUUUUUUU', '艺术家':U '\ u0443D \ u0414 \西飞\ x03HUUUUUUUUUUUUUUUUUU', '轨':85, '流派': 'Bebop','song':u'UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU \ u044f','year':u'UUUU'},'ID3TagV2':{}}

现在我想添加图像,以便可以在播放文件时显示它。

1 个答案:

答案 0 :(得分:0)

很遗憾,您的 ID3标记库 mp3_tagger不支持图像标记。 在该库的documentation中,找到以下内容:

  

允许的标签:

- artist;
- album;
- song;
- track;
- comment;
- year;
- genre;
- band (version 2.x);
- composer (version 2.x);
- copyright (version 2.x);
- url (version 2.x);
- publisher (version 2.x).

如您所见,cover标签或类似内容什么也没说。

因此,如果您想在mp3中添加类似封面的图像,则必须使用另一个库。

我建议使用eyedD3。要添加图片,请查看以下SO答案: here