Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

added a script to convert text to audio file#20

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
SAUMITRAJAGDALE wants to merge1 commit intorealpython:master
base:master
Choose a base branch
Loading
fromSAUMITRAJAGDALE:master
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsreadme.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,3 +34,4 @@
1. **32_stock_scraper.py**: Get stock prices
1. **33_country_code.py**: Convert country code to country name
1. **34_git_all_repos.py**: Clone all repositories from a public user or organization on Github. Usage: `python git_all_repos.py users USER_NAME` or `python git_all_repos.py orgs ORG_NAME`
1. **35_text_to_audio.py**: Convert text to audio file using gtts module
1 change: 1 addition & 0 deletionsrequirements.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,3 +3,4 @@ PyYAML==3.11
requests==2.12.4
wheel==0.24.0
lxml==3.8.0
gtts==1.1.8
19 changes: 19 additions & 0 deletionsscripts/35_text_to_audio.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@

from gtts import gTTS
import os

# Enter the text in string format which you want to convert to audio
mytext = "Hello World!, this audio is created using GTTS module."

# Specify the language in which you want your audio
language = 'en'

# Create an instance of gTTS class
myobj = gTTS(text=mytext, lang=language, slow=False)

# Method to create your audio file in mp3 format
myobj.save("hello_world.mp3")
print("Audio Saved")

# This will play your audio file
os.system("mpg321 welcome.mp3")

[8]ページ先頭

©2009-2025 Movatter.jp