Giter Club home page Giter Club logo

edge-tts's Introduction

edge-tts

edge-tts is a Python module that allows you to use Microsoft Edge's online text-to-speech service from within your Python code or using the provided edge-tts or edge-playback command.

Installation

To install it, run the following command:

$ pip install edge-tts

If you only want to use the edge-tts and edge-playback commands, it would be better to use pipx:

$ pipx install edge-tts

Usage

Basic usage

If you want to use the edge-tts command, you can simply run it with the following command:

$ edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.vtt

If you wish to play it back immediately with subtitles, you could use the edge-playback command:

$ edge-playback --text "Hello, world!"

Note the above requires the installation of the mpv command line player.

All edge-tts commands work in edge-playback as well.

Changing the voice

If you want to change the language of the speech or more generally, the voice.

You must first check the available voices with the --list-voices option:

$ edge-tts --list-voices
Name: Microsoft Server Speech Text to Speech Voice (af-ZA, AdriNeural)
ShortName: af-ZA-AdriNeural
Gender: Female
Locale: af-ZA

Name: Microsoft Server Speech Text to Speech Voice (am-ET, MekdesNeural)
ShortName: am-ET-MekdesNeural
Gender: Female
Locale: am-ET

Name: Microsoft Server Speech Text to Speech Voice (ar-EG, SalmaNeural)
ShortName: ar-EG-SalmaNeural
Gender: Female
Locale: ar-EG

Name: Microsoft Server Speech Text to Speech Voice (ar-SA, ZariyahNeural)
ShortName: ar-SA-ZariyahNeural
Gender: Female
Locale: ar-SA

...

$ edge-tts --voice ar-EG-SalmaNeural --text "مرحبا كيف حالك؟" --write-media hello_in_arabic.mp3 --write-subtitles hello_in_arabic.vtt

Custom SSML

Support for custom SSML has been removed since 5.0.0 because Microsoft has taken the initiative to prevent it from working. You cannot use custom SSML anymore.

Changing rate, volume and pitch

It is possible to make minor changes to the generated speech.

$ edge-tts --rate=-50% --text "Hello, world!" --write-media hello_with_rate_halved.mp3 --write-subtitles hello_with_rate_halved.vtt
$ edge-tts --volume=-50% --text "Hello, world!" --write-media hello_with_volume_halved.mp3 --write-subtitles hello_with_volume_halved.vtt
$ edge-tts --pitch=-50Hz --text "Hello, world!" --write-media hello_with_pitch_halved.mp3 --write-subtitles hello_with_pitch_halved.vtt

In addition, it is required to use --rate=-50% instead of --rate -50% (note the lack of an equal sign) otherwise the -50% would be interpreted as just another argument.

Note on the edge-playback command

edge-playback is just a wrapper around edge-tts that plays back the generated speech. It takes the same arguments as the edge-tts option.

Python module

It is possible to use the edge-tts module directly from Python. For a list of example applications:

edge-tts's People

Contributors

dependabot[bot] avatar lzieniew avatar maltoze avatar rany2 avatar rasan147 avatar scott306lr avatar vuizur avatar zhisenyang avatar zhoukuncheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edge-tts's Issues

Can I use another voice?

Hi,
There seems to be an optional argument to change the voice but it isn't working despite having listed the voices and carefully selecting the right name.
I am doing something wrong or is this just not working yet?

What's the maximum speed of playback

Hello!

Can you please tell me what's the maximum speed of playback? I tried and I can only increase it to +100% speed, is there a way to increase it further? Like Rate="+200%"?
Also, thank you for you work, It's really awesome! Big Respect!

Thanks in advance!

Adding a simple example of how to use the application in Python

First of all, thanks for creating this library, the results are amazing.

I thought it would be cool to have an example for the usage of the library in Python to output an mp3, because the current one in the examples folder was not applicable to my situation and I wasted too much time getting it to work.

So what I ended up with was:

def read_story(story: str, voice: str, filename: str):
    
    with open(f"{filename}.txt", "w", encoding="utf-8") as f:
        f.write(story)
    command = f'edge-tts --file "{filename}.txt" --write-media "{filename}.mp3" --voice {voice}'
    res = subprocess.check_output(command, shell=True)
    print(res)

Auto quit

Is there a way of auto quitting after finishing, instead of hanging on "Paused"?

Pronounciation and other finer control

Hi,
would it be possible to extend this to support defining pronounciations for specific words? I see Edge has a few different options in the XML and there is a step here that converts the passed in message to XML before sending of to Edge TTS so perhaps exposing another function to pass in the direct XML instead for "advanced" users might be an easy way to extend support for things that aren't implemented as nice, easy options?

What's the limitation length of text? It's ok to read in Edge browser, but it's not in EDGE-tts, warning "The command line is too long."

Once upon a time there was a rich farmer who had a lot of money, and his fields were all over the farm. But there is one big shortcoming in his happy life, that is, he has no children. When he went to town, he was often ridiculed
by fellow farmers who asked him why he had no children. At last he couldn't bear it anymore and became very angry. When he got home, he said angrily: "I must have a child, even a hedgehog." So his wife gave birth to a strange child
with a hedgehog on the upper body and a hedgehog on the lower body. boy. His wife was frightened and complained to him: "Look at you, this is the bad luck you brought." The farmer said helplessly: "The rice has become porridge, wha
t should I do now? This child has to be baptized, but who can do it?" How about being his godfather?" The wife sighed, "What name should I give him?"Let's call him Hans the Hedgehog."After being baptized, the priest said, "
He is covered with prickles all over, and he cannot sleep in an ordinary bed." So some hay was spread behind the stove, and Hans the Hedgehog slept on it. His mother could not nurse him because his thorns would hurt her. He lay like
this behind the stove for eight years, and his father, tired of him, thought to himself, "He might as well be dead!" But he lay there, living tenaciously. There was going to be a market in the city, and before going to the market,
the farmer asked his wife what she wanted to bring back. "I want some meat and some white bread," she said. Then he asked the maid, who wanted a pair of slippers and some embroidered stockings. Finally he asked the hedgehog, "What d
o you want, my Hans the hedgehog?" "Dear father," he said, "I want bagpipes." White bread, slippers for the maid, and embroidered stockings, then went behind the stove and gave the bagpipes to Hans the Hedgehog. Hans the Hedgehog to
ok the bagpipes and said, "Dear father, please go to the blacksmith's shop and shoe the cock. I'm going out on the cock and I won't come back." Hearing this, the father couldn't help but secretly rejoiced. , I thought I could ge
t rid of him now. He went at once and shod the cock, and Hans the Hedgehog rode off on the cock, taking with him some pigs and asses, which he was going to feed in the forest. They went into the forest, and the big rooster flew him
up a big tree. After that he stayed in the tree for many, many years, taking care of his donkey and pig until they were brought up, and his father never heard of him. For so many years he was still playing his bagpipes in the trees,
playing very beautiful music. Once, a king who was lost was passing by, and was surprised when he heard beautiful music, and immediately sent his attendants to find out where the flute was coming from. He looked around, only to fin
d a small animal high up in a tree that looked like a hedgehog playing on a rooster. So the king ordered his attendants to come forward and ask him why he was sitting there, and whether he knew the way to his kingdom. Hans the Hedge
hog came down from the tree, and said to the King that he would show the King the way if he would write a pledge that, when he got home, give him the first thing he found in the court. The king thought, "It's easy. Hans the Hedgeho
g can't read, and he doesn't know what I'm writing anyway." So the King took pen and ink, and wrote a pledge, and when he finished, Hans the Hedgehog showed him the way. , the king returned home safely. His daughter saw it from afar, and ran to meet him with
great joy, and kissed him happily. Then he thought of Hans the Hedgehog, and told her how it had happened, how he had been compelled to promise to give a gift of the first thing he found upon his return home to a very strange animal which rode like a horse. A
big rooster, playing beautiful music. But he didn't write what it meant, he wrote that it didn't deserve what it wanted. The princess was very happy when she heard this, and praised her father for what he had done, because it never occurred to her to live wit
h a hedgehog.Hans the Hedgehog looked after his donkey and pig as usual, and often sat happily in a tree and played on his bagpipes.One day, another king passed by with his entourage and envoys. They also lost their way. The forest was so large and dens
e that they lost their way home. He also heard the music not far away, so he asked the messenger what it was and ordered him to go and have a look. The messenger went under the tree and saw a cock on the top of the tree, and Hans the Hedgehog was riding on the
cock's back. The messenger asked him what he was doing up there, "I am letting my donkey and my pigs go. What do you want to do?" The messenger said that they were lost and could not return to their kingdom, and asked him if he could show them the way. Hans th
e Hedgehog and the Cock came down from the tree, and said to the old King that if the King would give him the first thing he found before the palace, he would tell him the way. The king replied simply: "Yes," and wrote a pledge to Hans the Hedgehog. Then Hans r
ode ahead on the cock, and showed them the way, and the king returned safely to his kingdom. When he arrived at the courtyard in front of the palace, there was joy there. The King had an only daughter who was very beautiful, and she ran up to meet him, and thre
w her arms about his neck, and was very glad to have her old father back. She asked where he had been for so long. He told how he had lost his way, and could hardly return, but as he was passing through a great forest, a half-hedgehog, half-human monster riding
a rooster bagpipe in a high tree pointed out to him and helped him out of the forest, but in return he promised to give him the first thing he met in the court, and now it was she he met first, and the king was very sorry for it.', 'Unexpectedly, the princess
spoke surprisingly, saying: For the father she loves, she is willing to go with Hans when he comes.Hans the Hedgehog still took good care of his pigs, which grew bigger and bigger until the whole forest was full. So Hans the Hedgehog decided not to live in
the woods any more, and he sent a message to his father, saying that all the pigpens in the village should be emptied, and that he would drive back a large herd, and invite all who could butcher a pig. His father was very embarrassed when he found out, for he h
ad always thought that Hans the Hedgehog was dead long ago. Hans the Hedgehog sat comfortably on the back of the rooster, and drove a group of pigs into the village. He gave an order, and the slaughter began. I saw the knife rising and the ax falling, a piece o
f blood and flesh, and the sound of killing a pig could be heard for miles around! After the matter was over, Hans the Hedgehog said, "Father, please go to the blacksmith's and paw the cock again. This time I will never come back after I leave." Father pawed t
he cock again, and he felt a burst of relief. , because Hans the Hedgehog is never coming back.Hans the Hedgehog rode the rooster to the first kingdom. The king there ordered that as long as you see a person riding a rooster and holding a bagpipe, everyone
should raise their bows and arrows, pick up their knives and guns, and block him from outside the palace. So when Hans the Hedgehog came to the gate, they all rushed upon him with their spears raised. He struck the cock with his shoe, and it flew up, over the g
ate, and landed at the king's window. Hans cried out in a loud voice that the king must keep his promise and give him what was his, or he would kill the king and his daughter. The king was very frightened at this moment, and begged his daughter to go with Hans
, only in this way could save her own life and her father's life. So she put on all white, and took a six-horse carriage which her father had given her, and a company of beautiful maids, and gold and treasure, and got into the carriage, and put Hans, the cock,
and the bagpipes in her Beside, and then set off together to leave. The king thought he would never see his daughter again, but he never expected that, not far from the city, Hans the Hedgehog stripped off her beautiful clothes, and then stabbed her bloody wit
h his thorns. "This is the reward for your hypocrisy and cunning," he said. "Go away, I won't have you." After saying this, he drove her back, and she was despised all her life ever since.Hans the Hedgehog rode on the rooster and played on the bagpipes, an
d went on to the kingdom of the second king, whom he had shown the way for. The king ordered that anyone who looked like Hans the Hedgehog should salute him, keep him safe, sing long live to him, and lead him to the palace.Unexpectedly, when the king's dau
ghter saw him, she was startled by his strange appearance. At this time, she warned herself not to change her mind, because she had made a promise to her father. So she came out to meet Hans the Hedgehog, and they became friends for a hundred years. The two wal
ked to the dining table in the palace, sat down side by side, and enjoyed the delicious food and wine. When evening came, it was time for them to go to bed, but she was afraid of the thorns on his body, and he reassured her that there was no need to be afraid,
saying that she would not suffer any harm. At the same time, he also asked the old king to send four soldiers to guard the door of the bridal chamber and light a fire. Before he entered the bridal chamber and was about to go to bed, he would crawl out of the he
dgehog skin and throw the hedgehog skin beside the bed. They were to run there at once, take the hedgehog skin and throw it into the fire, and not leave until it was all gone. When the clock struck eleven o'clock, he stepped into the bridal chamber, took off t
he hedgehog skin, and threw it beside the bed. The soldier ran over quickly, picked up the hedgehog skin and threw it into the fire. When the fire burned his skin to ashes, he was saved and lay on the bed in a human form, his whole body black as if he had been
burned by the fire. The king sent a physician, who scrubbed and anointed him with expensive ointments, and soon his skin turned white, and he became a handsome young man. The king's daughter was very happy to see him like this, and they got up happily the next
morning, and after eating and drinking together, the wedding was held again in a solemn atmosphere, and Hans the Hedgehog succeeded the old king's throne.A few years later he took his wife to see his father and told him that he was his son. But his father
has repeatedly stated that he has no son, saying that there was one who was born like a prickly hedgehog and left long ago, not knowing where to go. Hans proved who he was, and the old father was delighted, and followed him to his kingdom.

Audio stream

HI, How to deal with audio stream? It worked well earlier, but that don't work any more now.

# TODO: implement this:
"""
X-RequestId:xxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type:application/json; charset=utf-8
Path:response
{"context":{"serviceTag":"yyyyyyyyyyyyyyyyyyy"},"audio":{"type":"inline","streamId":"zzzzzzzzzzzzzzzzz"}}

It's a new request

when I run "edge-tts --text "Hello, world!" --write-media hello.mp3", I hope get a hello.vtt and hello.srt in the current dir at the same time. (just like what Whisper do), or at least one of them.

thanks.

SubMaker: Improve broken offset solution

After about the 40 minute mark, the current solution in submaker doesn't work too well. It works fine for a few hours but at 4 hours it drifts about 3 minutes from reality.

It cannot handle French sentences?

fr1 = '''Prométhée le lion et l'éléphant.Le lion se "plaignait souvent de" Prométhée, bien que Prométhée l'ait rendu grand et puissant"'''
fr2 = '.' + fr1.replace("'","'").replace('"','"') + '.'
os.system(f'edge-tts --voice fr-FR-HenriNeural --text """{fr1}""" --write-media 211.mp3')

考虑以下情况,其中fr1字串的形式有可能是以下几种(既有单引号,又有双引号。而且可能在行首/尾)
Prométhée le lion et l'éléphant.Le
Prométhée le "lion et l'éléphant.Le"
Prométhée le lion et l'éléphant.Le'
"Prométhée le lion" et l'éléphant.Le

Import not working

after installing using pip, I tried running the example script but there seem to be a problem importing the module.
If I do a pip list, I can see edge-tts 2.2.2 but when I try to run the example script, I get the following error:
import edgeTTS
ModuleNotFoundError: No module named 'edgeTTS'

does it has a words limit?

Traceback (most recent call last):
  File "/opt/miniconda3/bin/edge-tts", line 8, in <module>
    sys.exit(main())
  File "/opt/miniconda3/lib/python3.9/site-packages/edge_tts/util.py", line 157, in main
    asyncio.get_event_loop().run_until_complete(_main())
  File "/opt/miniconda3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/opt/miniconda3/lib/python3.9/site-packages/edge_tts/util.py", line 150, in _main
    await _tts(args)
  File "/opt/miniconda3/lib/python3.9/site-packages/edge_tts/util.py", line 33, in _tts
    async for i in tts.run(
  File "/opt/miniconda3/lib/python3.9/site-packages/edge_tts/communicate.py", line 302, in run
    await websocket.send_str(request)
  File "/opt/miniconda3/lib/python3.9/site-packages/aiohttp/client_ws.py", line 151, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "/opt/miniconda3/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 690, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "/opt/miniconda3/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 601, in _send_frame
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport

with
edge-tts --voice zh-CN-XiaoxiaoNeural -f /Users/wei/Downloads/真实的春天\,我和小姨的13年.txt --write-media 真实的春天.mp3

真实的春天,我和小姨的13年.txt

Support for Basque models

Hi! 👋

I've just noticed that there is no model for the Basque (eu-ES) models, altough they seem to be available here. Could they be added to the list of voices?

Thanks for the great work!

Limits on the TRUSTED_CLIENT_TOKEN

Hi!
I would like to ask if there is a limit to the TRUSTED_CLIENT_TOKEN used in the library, like number of synthesis or somethign like that.

Thank you for your help.

The input example doesn't seem to work on Windows

Hello,

I just realized that the input example linked in the README seems to be broken on Windows 10 (in my case Python 3.10.2) due to a bug in playsound.

So I think it would make sense to change it to something like this:

import asyncio
import tempfile
import edge_tts

async def main():
    """
    Main function
    """
    TEXT = "Hello World!"
    VOICE = "en-GB-SoniaNeural"
    OUTPUT_FILE = "test.mp3"

    communicate = edge_tts.Communicate()
    with tempfile.NamedTemporaryFile() as temporary_file:
        async for i in communicate.run(TEXT, voice=VOICE):
            if i[2] is not None:
                temporary_file.write(i[2])
        
            temporary_file.seek(0)
            with open(OUTPUT_FILE, "wb") as f:
                f.write(temporary_file.read())
            

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main())

(No idea if the code fully makes sense like this, one could probably also do without the tempfile, but at least it works for me.)

Can only use one voice per gender

Version: 5.0.0
Many languages can only use one voice per gender, for example, Chinese femal can only use zh-CN-XiaoxiaoNeural but can't use zh-CN-XiaoxuanNeural. Chinese male can only use zh-CN-YunyangNeural.

# Success
edge-playback --text "Hello, world!" --voice zh-CN-XiaoxiaoNeural
# Fail
$ edge-playback --text "Hello, world!" --voice zh-CN-XiaoxuanNeural

Media file: /tmp/tmpy3dtrfg6
Subtitle file: /tmp/tmphm0_zpim

Failed to recognize file format.


Exiting... (Errors when loading file)

Wrong subtitles times

> edge-tts --text "Hello, world!" --write-media hello.mp3
WEBVTT

00:00:00.100 --> 00:00:01.538
Hello

00:00:00.787 --> 00:00:02.275
world

hello dones't read so slow and world start before hello finished

Request support for subtitle files in SRT format

Similar applications.
https://voicenotebook.com/srtspeaker.php (Google's text-to-speech is terrible)
https://github.com/bdleavitt/azure-text-to-speech-for-dubbing (might have worked well, but didn't run, no reply from the author)

It would be a lot easier for non-verbal programmers to record some videos for screen recording.I once recorded a 13-minute video and the voiceover consumed four whole days and it was a nightmare.Because it would always say the wrong thing and start again ......
I know this project is already great and supports ssml, but editing ssml is also more time consuming, editing srt can be done very quickly with the help of other subtitle software.

Possible problem: Let's say a sentence in SRT has a timeline of 6 seconds, but using Microsoft Edge's text-to-speech service it takes 8 seconds to actually play the sentence; in this case, you need to automatically adjust the speech speed of the sentence.

Added AUR package

Hi,

I just wanted to inform that I've created an Arch Linux AUR package here: https://aur.archlinux.org/packages/python-edge-tts
Please let me know if you approve of this, if you'd like me to add you as a co-maintainer on this package, and whether you'd consider adding install instructions (eg. via yay or paru) to the README.
If you see any glaring problems with how I've written it / how I'm installing your package, please let me know.

Thanks!

Progress bar for big pdf files

It would be great if you could add a progress bar as it would be quite useful when sending a big pdf with many pages, say 100+

The program currently eventually terminates successfully if you wait long enough but I'd like to know how long there is to wait.

RuntimeError: Event loop is closed

Run edge-tts --list-voices command, error message: raise RuntimeError('Event loop is closed')
Running edge-tts --text "Hello, world!" > hello.mp3 command, the generated MP3 file has no sound.

Windows11
Python 3.8.10

Can it also produce .srt subtitle according the comma/period?

Hi
thanks the code. It's helpful.
Can you add a new function for it, to produce .srt subtitle according the comma/period/question mark? like,
1
00:00:00,000 --> 00:00:11,400
美专家称俄亥俄州5到20年后获献大批癌症患者,绿乙烯对身体有哪些危害?美方的应对是否合理?

2
00:00:11,405 --> 00:00:21,200
当地时间3日晚,一列运载危险化学品的火车在美国俄亥俄州脱轨起火,导致危险化学物质绿乙烯泄漏。

文本数量限制

Hello, is there a character limit for the input text, such as not being able to generate speech if the text exceeds a certain number of characters?

安装好后无法运行

[root@localhost ~]# pip3 install edge-tts
Requirement already satisfied: edge-tts in /usr/local/python3/lib/python3.7/site-packages (6.1.3)
Requirement already satisfied: aiohttp>=3.8.0 in /usr/local/python3/lib/python3.7/site-packages (from edge-tts) (3.8.4)
Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (1.8.2)
Requirement already satisfied: typing-extensions>=3.7.4 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (4.5.0)
Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (6.0.4)
Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (1.3.1)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (4.0.2)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (3.1.0)
Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (1.3.3)
Requirement already satisfied: asynctest==0.13.0 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (0.13.0)
Requirement already satisfied: attrs>=17.3.0 in /usr/local/python3/lib/python3.7/site-packages (from aiohttp>=3.8.0->edge-tts) (22.2.0)
Requirement already satisfied: idna>=2.0 in /usr/local/python3/lib/python3.7/site-packages (from yarl<2.0,>=1.0->aiohttp>=3.8.0->edge-tts) (3.4)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@localhost ~]# edge-tts
bash: edge-tts: command not found...
[root@localhost ~]#

Is it compatible with windows 11?

I tried to run it on windows 11, but I get this issue:
"'edge-tts' is not recognized as an internal or external command, operable program or batch file."

I tried to put it in the PATH, but it didn't resolve the issue.

write-subtitles not work

edge-tts -t "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt
The mp3 file is fine, but the srt file is empty

安装成功,在执行示例时出现『dquote』

Installation successful, 'dquote' error occurred when running the example.
image

How to deal with this situation, because I am not very familiar with programming and cannot find relevant steps in the instructions. Please provide some guidance.
Operating environment: MacOS 13.2.1 + Python 3.11.2

出现这种情况应该如何处理,因为对编程不是很懂,说明里未发现相关步骤,烦请解答下
运行环境:MacOS 13.2.1 + Python 3.11.2

Error while closing mp3 file

Screenshot 2023-01-05 215901
The section marked in red. I can't fix this issue. I have tried try except, still getting the same error.
Please help me fix this. Also it seems that the media player on windows 10 unable to open it.

Works in my windows 11 environment, but does not work in Centos 7 environment, reports unable to connect: speech.platform.bing.com:443

python3 --version
Python 3.9.10

same lan.

[root@sh1-mbp-122 bin]# ./edge-tts  --voice zh-CN-YunyangNeural  --text "朋友们或许还有一个疑问,就是不知道科大讯飞和neospeech哪个更好。据我的体会,它们其实各有优点。" > hello.mp3
Traceback (most recent call last):
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
    raise exceptions[0]
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
    sock = await self._connect_sock(
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
    await self.sock_connect(sock, address)
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
    return await fut
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/asyncio/selector_events.py", line 507, in _sock_connect
    sock.connect(address)
OSError: [Errno 101] Network is unreachable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/.cache/activestate/4fab4d29/usr/bin/./edge-tts", line 8, in <module>
    sys.exit(main())
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/edge_tts/util.py", line 162, in main
    asyncio.run(_main())
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/edge_tts/util.py", line 155, in _main
    await _tts(args)
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/edge_tts/util.py", line 33, in _tts
    async for i in tts.run(
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/edge_tts/communicate.py", line 259, in run
    async with session.ws_connect(
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/client.py", line 776, in _ws_connect
    resp = await self.request(
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/root/.cache/activestate/4fab4d29/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host speech.platform.bing.com:443 ssl:default [Network is unreachable]

edge-playback report an error

PS D:\DevScript> edge-playback --text "Hello, world!"

Media file: C:\Users\tuike\AppData\Local\Temp\tmp1eek28_q
Subtitle file: C:\Users\tuike\AppData\Local\Temp\tmpqdfqxmhz

Traceback (most recent call last):
  File "d:\develop\python\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:\develop\python\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Develop\Python\Python38\Scripts\edge-tts.exe\__main__.py", line 7, in <module>
  File "d:\develop\python\python38\lib\site-packages\edge_tts\util.py", line 156, in main
    asyncio.get_event_loop().run_until_complete(_main())
  File "d:\develop\python\python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "d:\develop\python\python38\lib\site-packages\edge_tts\util.py", line 149, in _main
    await _tts(args)
  File "d:\develop\python\python38\lib\site-packages\edge_tts\util.py", line 32, in _tts
    media_file = open(args.write_media, "wb")  # pylint: disable=consider-using-with
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\tuike\\AppData\\Local\\Temp\\tmp1eek28_q'
Failed to recognize file format.

Exiting... (Errors when loading file)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.