舌尾⭢舌背

This commit is contained in:
xiaolai
2024-08-26 07:28:32 +08:00
parent 1c2a562f35
commit 1d9beef921
3 changed files with 5 additions and 61 deletions

View File

@@ -13,17 +13,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The history saving thread hit an unexpected error (DatabaseError('database disk image is malformed')).History will not be written to the database.\n"
]
}
],
"outputs": [],
"source": [
"from openai import OpenAI\n",
"import re\n",
@@ -454,54 +446,6 @@
"print(f\"\\nAudio file saved as {whole_audio_filename}!\") \n",
"IPython.display.Audio(whole_audio_filename)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Generating audio from your own text.\n",
"\n",
"text = \"\"\"\n",
"\n",
"\"\"\"\n",
"\n",
"IPython.display.Audio(get_openai_tts_audio(text, mp3_file_path))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Generating audio from a text file.\n",
"\n",
"text_file_path = '/Users/joker/Desktop/Ten Lessons I Wish I Had Been Taught'\n",
"\n",
"# if file has no extension, add .mp3, if it has, replace it with .mp3\n",
"if text_file_path.endswith('.md'):\n",
" mp3_file_path = text_file_path.replace('.md', '.mp3')\n",
"else:\n",
" mp3_file_path = f'{text_file_path}.mp3'\n",
"\n",
"text = markdown_to_text(read_text_from_file(text_file_path))\n",
"\n",
"IPython.display.Audio(get_openai_tts_audio(text, mp3_file_path))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# add meta data to all mp3 in current dir\n",
"for file in os.listdir():\n",
" if file.endswith('.mp3'):\n",
" add_metadata(file, 'Artwork.png', 'tts', 'Daily Speech Training', 'SPEECH')"
]
}
],
"metadata": {