Skip to content

Commit

Permalink
Merge pull request #97 from barseghyanartur/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
barseghyanartur authored Dec 25, 2024
2 parents b8a6bc2 + c45b565 commit 7c001e7
Show file tree
Hide file tree
Showing 40 changed files with 782 additions and 881 deletions.
6 changes: 3 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"filename": "examples/django_example/project/settings/base.py",
"hashed_secret": "2e56b31925af569c194d2cc738d1f1bc22b63df0",
"is_verified": true,
"line_number": 66
"line_number": 67
}
],
"examples/sqlalchemy_example/faker_file_admin/alembic/versions/2695cb77cdf2_create_product_table.py": [
Expand Down Expand Up @@ -197,7 +197,7 @@
"filename": "src/faker_file/tests/test_sftp_server.py",
"hashed_secret": "e8662cfb96bd9c7fe84c31d76819ec3a92c80e63",
"is_verified": true,
"line_number": 84
"line_number": 86
}
],
"src/faker_file/tests/test_sftp_storage.py": [
Expand All @@ -219,5 +219,5 @@
}
]
},
"generated_at": "2024-11-14T22:15:37Z"
"generated_at": "2024-12-24T23:25:39Z"
}
61 changes: 43 additions & 18 deletions examples/customizations/marytts_mp3_generator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,48 @@ def generate(self: "MaryTtsMp3Generator") -> bytes:
# Initialize with args
mary_tts = MaryTTS(locale=self.locale, voice=self.voice)

# Generate temporary filename for WAV file
filename = tempfile.NamedTemporaryFile(
prefix="_merytts_", suffix=".wav"
).name

# Write WAV file
with open(filename, "wb") as file:
file.write(mary_tts.speak(self.content))

# Convert WAV to MP3
ffmpeg.input(filename).output(filename + ".mp3").run()

with open(filename + ".mp3", "rb") as _fake_file:
return_value = _fake_file.read()
# Create temporary WAV file in memory
with tempfile.NamedTemporaryFile(
delete=False,
suffix=".wav",
) as temp_wav:
temp_wav.write(mary_tts.speak(self.content))
temp_wav_path = temp_wav.name

# Convert WAV to MP3 and store in memory
with tempfile.NamedTemporaryFile(
delete=False,
suffix=".mp3",
) as temp_mp3:
ffmpeg.input(temp_wav_path).output(temp_mp3.name).run()

# Read the MP3 file content into memory
with open(temp_mp3.name, "rb") as mp3_file:
mp3_content = mp3_file.read()

# Clean up temporary files
os.remove(filename)
os.remove(filename + ".mp3")

return return_value
os.remove(temp_wav.name)
os.remove(temp_mp3.name)

return mp3_content

# # Generate temporary filename for WAV file
# filename = tempfile.NamedTemporaryFile(
# prefix="_merytts_", suffix=".wav"
# ).name
#
# # Write WAV file
# with open(filename, "wb") as file:
# file.write(mary_tts.speak(self.content))
#
# # Convert WAV to MP3
# ffmpeg.input(filename).output(filename + ".mp3").run()
#
# with open(filename + ".mp3", "rb") as _fake_file:
# return_value = _fake_file.read()
#
# # Clean up temporary files
# os.remove(filename)
# os.remove(filename + ".mp3")
#
# return return_value
5 changes: 2 additions & 3 deletions examples/django_example/project/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from contextlib import suppress

from .core import PROJECT_DIR

Expand Down Expand Up @@ -200,7 +201,5 @@


# Do not put any settings below this line
try:
with suppress(ImportError):
from .local_settings import * # noqa
except ImportError:
pass
73 changes: 34 additions & 39 deletions examples/requirements/common.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --no-strip-extras examples/requirements/common.in -o examples/requirements/common.txt
aiohappyeyeballs==2.4.3
aiohappyeyeballs==2.4.4
# via aiohttp
aiohttp==3.11.2
aiohttp==3.11.11
# via edge-tts
aiosignal==1.3.1
aiosignal==1.3.2
# via aiohttp
async-timeout==5.0.1
# via aiohttp
attrs==24.2.0
attrs==24.3.0
# via aiohttp
azure-core==1.32.0
# via azure-storage-blob
azure-storage-blob==12.24.0
# via pathy
bcrypt==4.2.0
bcrypt==4.2.1
# via paramiko
beautifulsoup4==4.12.3
# via xml2epub
boto3==1.35.61
boto3==1.35.87
# via pathy
botocore==1.35.61
botocore==1.35.87
# via
# boto3
# s3transfer
brotli==1.1.0
# via fonttools
cachetools==5.5.0
# via google-auth
certifi==2024.8.30
certifi==2024.12.14
# via
# edge-tts
# requests
Expand All @@ -39,39 +37,37 @@ cffi==1.17.1
# weasyprint
chardet==5.2.0
# via reportlab
charset-normalizer==3.4.0
charset-normalizer==3.4.1
# via requests
click==8.1.7
click==8.1.8
# via
# gtts
# typer
coverage[toml]==7.6.5
coverage[toml]==7.6.9
# via pytest-cov
cryptography==43.0.3
cryptography==44.0.0
# via
# azure-storage-blob
# paramiko
cssselect2==0.7.0
# via weasyprint
defusedxml==0.7.1
# via odfpy
edge-tts==6.1.18
edge-tts==7.0.0
# via -r examples/requirements/common.in
et-xmlfile==2.0.0
# via openpyxl
exceptiongroup==1.2.2
# via pytest
fonttools[woff]==4.55.0
fonttools[woff]==4.55.3
# via weasyprint
frozenlist==1.5.0
# via
# aiohttp
# aiosignal
google-api-core==2.23.0
google-api-core==2.24.0
# via
# google-cloud-core
# google-cloud-storage
google-auth==2.36.0
google-auth==2.37.0
# via
# google-api-core
# google-cloud-core
Expand All @@ -98,7 +94,7 @@ iniconfig==2.0.0
# via pytest
isodate==0.7.2
# via azure-storage-blob
jinja2==3.1.4
jinja2==3.1.5
# via xml2epub
jmespath==1.0.1
# via
Expand Down Expand Up @@ -135,7 +131,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==10.4.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand All @@ -144,13 +140,13 @@ pillow==10.4.0
# xml2epub
pluggy==1.5.0
# via pytest
propcache==0.2.0
propcache==0.2.1
# via
# aiohttp
# yarl
proto-plus==1.25.0
# via google-api-core
protobuf==5.28.3
protobuf==5.29.2
# via
# google-api-core
# google-cloud-storage
Expand All @@ -170,9 +166,9 @@ pygments==2.18.0
# via rich
pynacl==1.5.0
# via paramiko
pyphen==0.15.0
pyphen==0.17.0
# via weasyprint
pytest==8.3.3
pytest==8.3.4
# via
# pathy
# pytest-cov
Expand Down Expand Up @@ -203,11 +199,11 @@ rich==13.9.4
# via typer
rsa==4.9
# via google-auth
s3transfer==0.10.3
s3transfer==0.10.4
# via boto3
shellingham==1.5.4
# via typer
six==1.16.0
six==1.17.0
# via
# azure-core
# google-cloud-storage
Expand All @@ -217,38 +213,37 @@ smart-open==6.4.0
# via pathy
soupsieve==2.6
# via beautifulsoup4
srt==3.5.3
# via edge-tts
tablib==3.7.0
# via -r examples/requirements/common.in
tabulate==0.9.0
# via edge-tts
tinycss2==1.4.0
# via
# cssselect2
# weasyprint
tinyhtml5==2.0.0
# via weasyprint
tomli==2.1.0
# via
# coverage
# pytest
typer==0.13.0
typer==0.15.1
# via
# pathy
# typer-cli
typer-cli==0.13.0
typer-cli==0.15.1
# via pathy
typing-extensions==4.12.2
# via
# azure-core
# azure-storage-blob
# multidict
# edge-tts
# python-docx
# python-pptx
# rich
# typer
urllib3==2.2.3
urllib3==2.3.0
# via
# botocore
# requests
weasyprint==63.0
weasyprint==63.1
# via -r examples/requirements/common.in
webencodings==0.5.1
# via
Expand All @@ -259,7 +254,7 @@ xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.6
# via -r examples/requirements/common.in
yarl==1.17.1
yarl==1.18.3
# via aiohttp
zopfli==0.2.3.post1
# via fonttools
10 changes: 2 additions & 8 deletions examples/requirements/debug.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --no-strip-extras examples/requirements/debug.in -o examples/requirements/debug.txt
asttokens==2.4.1
asttokens==3.0.0
# via stack-data
decorator==5.1.1
# via
# ipdb
# ipython
exceptiongroup==1.2.2
# via ipython
executing==2.1.0
# via stack-data
ipdb==0.13.13
# via -r examples/requirements/debug.in
ipython==8.29.0
ipython==8.31.0
# via
# -r examples/requirements/debug.in
# ipdb
Expand All @@ -34,12 +32,8 @@ pure-eval==0.2.3
# via stack-data
pygments==2.18.0
# via ipython
six==1.16.0
# via asttokens
stack-data==0.6.3
# via ipython
tomli==2.1.0
# via ipdb
traitlets==5.14.3
# via
# ipython
Expand Down
Loading

0 comments on commit 7c001e7

Please sign in to comment.