It's getting more and more fun, using ChatGPT+Python to make audio novels!

Rookie Learning Python-Part 623 Original

Now our member group of hundreds of people has become more and more advanced, use chatgpt suits to play! Some play Baidu Wenyiwen to grab orders after 6 o'clock in the morning every morning, some play WeChat robots to help people arrange and receive orders, and some play salted fish to guide college students' papers!

Use chatgpt4 to play various tricks! You can also earn dozens of dollars a day. Although there is not much money, once you can use technology to make money, you will have a steady stream of motivation to learn. For example, if you learn python and earn 100 yuan every day, you will have a strong motivation to learn and research! Rather than from getting started to giving up.

Closer to home, recently we are going to teach you how to play this in the member group, and use chatgpt to make audio novels . In fact, the powerful GPT is mainly used to generate text, and then Python is used to generate different voices in batches for voice synthesis.

27e543742851192175883880b3679620.png

Let’s take a look. In fact, chatgpt has many ways to play and can be used in many applications. This time we are making audio novels. Many people know how to use GPT4 to generate text, and our official account has also written more than 10 columns. If you still don’t know what GPT is, you can face the wall!

Let's briefly talk about how to make an audio novel!

1. Generating novels with GPT4

It is best if you have GPT4 API in hand, if not, you can use 3.5. About how to use Python to call GPT API, read this article ( 10 minutes! Write a role-playing chatgpt chatbot with context function in Python! Part 1! ), we are limited to space here and use web page generation to show you.

For example, we let gpt4 write a simple novel "a novel about a boy and a girl in an elevator"

77d732e1c1551da180d2edaaa3c9e7dc.png

Then we need to convert text to speech. There are many text-to-speech tools on the market, but we do it in batches. It must be a technology to play with! We use Python to transfer in batches.

6a5988c4a2efe4e7c5cfe097ab1c5940.png

The above are the relatively large companies and platforms for speech synthesis in the market at present. The current one is better than Microsoft, but the threshold is also relatively high. You can study it yourself. Here we use Baidu to make a demo for everyone. Tell me how you did it.

2. Apply for Baidu token

Because Baidu has a lot of applications, you can take a look at Baidu's brain platform (there are many, many AI services such as image recognition, voice recognition, video, text, etc.), the business we are actually going to do is a speech synthesis.

cf9537149769f264e8e595e3d93fd1cc.png

Then we are going to apply for a token, that is, apply for an application, and then this application will give you a token.

163ed5bb10832db27ddecc1d8440e8a8.png

After the application is completed, you will get the 3 values ​​APP_ID, APP_KEY, SECRECT_KEY. These 3 values ​​are very useful and will be used when writing code later.

3. Call Baidu API for language synthesis

Baidu's API has two modes for consulting, one is to send it through a post request, and the other is to directly encapsulate the call through Baidu's python AipSpeech library. We must choose the simplest and most trouble-free, we can use AipSpeech. Then the following is the core code:

7f9425120971e34313b636f16db2a0a3.png

Then run it to generate a synthesized novel voice, among which there are many parameters in the synthesis function, you need to check Baidu's api documentation in detail, here we choose the girl's voice, and then the volume is medium, and the speech speed is also medium, everyone You can adjust the parameters yourself.

Because the generated result is binary text, we may write it into an mp3 file.

515a4a06b7dd9a82c59cd585c11cafea.png

The synthesis speed is very fast, it can be done in about 5 seconds, if there are more text content, it will take longer. Let's listen to the effect:

Another version of this demo synthesized with another nice voice:

If it is combined with such a cover, it will feel more like an electronic novel.

90d040819d8fdf2863689cefdc456133.png

Well, the above is today’s sharing. There are many things that can be explored in it. The combination of text + voice + painting can generate many interesting ideas, some of which are even commercially available. Students who are interested can try it. If you are very interested in chatgpt and interested in making electronic audiobooks, you can join our planet.


Planet will provide a complete series of application source code + documentation + video content, which is very valuable!

Finally, recommend our ChatGPT community. The planet will provide all the source code, video and communication services of the chatgpt advanced chapter. It is still an early bird price, if you are interested, you can join us.

364f0addf49d6def5971740c548f25e2.jpeg

The original price is 219, and the trial operation is 159 for one year  . Students who join will receive the following benefits:

1). Free 3-week introductory python course worth 99 yuan 44 video lessons (exclusively recorded by the Cainiao team) 10G video (1 discount coupon), planet students can buy it for 9.9 yuan (limited time benefits)

2). Send a gift with a market price of 30 yuan exclusive to ChatGPT

3). Send the content of 28 tutorials in the column group "Playing Chatgpt Cheats",

4), advanced video courses for exclusive members of the planet

5). Planet book gift

推荐阅读:
入门: 最全的零基础学Python的问题  | 零基础学了8个月的Python  | 实战项目 |学Python就是这条捷径
干货:爬取豆瓣短评,电影《后来的我们》 | 38年NBA最佳球员分析 |   从万众期待到口碑扑街!唐探3令人失望  | 笑看新倚天屠龙记 | 灯谜答题王 |用Python做个海量小姐姐素描图 |碟中谍这么火,我用机器学习做个迷你推荐系统电影
趣味:弹球游戏  | 九宫格  | 漂亮的花 | 两百行Python《天天酷跑》游戏!
AI: 会做诗的机器人 | 给图片上色 | 预测收入 | 碟中谍这么火,我用机器学习做个迷你推荐系统电影
小工具: Pdf转Word,轻松搞定表格和水印! | 一键把html网页保存为pdf!|  再见PDF提取收费! | 用90行代码打造最强PDF转换器,word、PPT、excel、markdown、html一键转换 | 制作一款钉钉低价机票提示器! |60行代码做了一个语音壁纸切换器天天看小姐姐!

Guess you like

Origin blog.csdn.net/cainiao_python/article/details/130838156