1
0
mirror of https://github.com/home-assistant/core.git synced 2025-08-12 06:50:00 +00:00
Files
.devcontainer
.github
.vscode
homeassistant
machine
pylint
rootfs
script
hassfest
scaffold
translations
__init__.py
alexa_locales.py
bootstrap
check_dirty
check_format
const.py
countries.py
currencies.py
gen_requirements_all.py
inspect_schemas.py
install_integration_requirements.py
languages.py
lint
lint_and_test.py
microsoft_tts.py
monkeytype
ruff.toml
run-in-env.sh
server
setup
split_tests.py
update
util.py
version_bump.py
tests
.core_files.yaml
.coveragerc
.dockerignore
.git-blame-ignore-revs
.gitattributes
.gitignore
.hadolint.yaml
.pre-commit-config.yaml
.prettierignore
.strict-typing
.yamllint
CLA.md
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile
Dockerfile.dev
LICENSE.md
MANIFEST.in
README.rst
build.yaml
codecov.yml
mypy.ini
pyproject.toml
requirements.txt
requirements_all.txt
requirements_test.txt
requirements_test_all.txt
requirements_test_pre_commit.txt
core/script/microsoft_tts.py

27 lines
806 B
Python

"""Helper script to update supported languages for Microsoft text-to-speech (TTS)."""
from pathlib import Path
from lxml import html
import requests
from .hassfest.serializer import format_python_namespace
URL = "https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support"
XPATH_QUERY = "//section[@data-tab='tts']/table[1]/tbody/tr/td[1]/code/text()"
req = requests.get(URL)
req.raise_for_status()
tree = html.fromstring(req.content)
supported_languages_raw = tree.xpath(XPATH_QUERY)
supported_languages = {s.lower() for s in supported_languages_raw}
Path("homeassistant/generated/microsoft_tts.py").write_text(
format_python_namespace(
{
"SUPPORTED_LANGUAGES": supported_languages,
},
generator="script.microsoft_tts",
)
)