vits_strings.py

时间: 2023-05-15 09:04:06 浏览: 71
vits_strings.py是一个Python脚本文件,其中包含了一些字符串操作相关的函数。 这个脚本文件中包含的函数有: 1. strip_list:去除一个列表中所有字符串的首尾空格。 2. clean_str:去除字符串中的非字母和数字字符。 3. nltk_clean_str:使用NLTK工具去除字符串中的停用词和标点符号。 4. tokenize:将字符串拆分成单词列表。 5. sentence_segment:将字符串拆分成句子列表。 6. get_word_freq:获取单词出现频率。 这些函数都是基于Python内置的字符串操作函数和NLTK工具来实现的,可以方便地进行字符串的处理和分析。这些函数可以用于自然语言处理、文本挖掘、数据分析等领域。如果需要进行字符串操作的时候,可以考虑使用这个脚本文件中的函数来提高效率。
相关问题

Traceback (most recent call last): File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\routes.py", line 442, in run_predict output = await app.get_blocks().process_api( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1389, in process_api result = await self.call_function( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1094, in call_function prediction = await anyio.to_thread.run_sync( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run result = context.run(func, *args) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\utils.py", line 703, in wrapper response = f(*args, **kwargs) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\vits_chinese-2.0\app.py", line 65, in tts_calback return "成功", gr.outputs.Download(output_filepath, mime_type="audio/wav") AttributeError: module 'gradio.outputs' has no attribute 'Download'

非常抱歉,看来在我之前的回答中犯了一个错误。我混淆了 `gradio` 和 `gr` 的命名空间。 在 `gradio` 中,下载组件的正确类名是 `gradio.outputs.FileDownload` 而不是 `gradio.outputs.Download`。因此,您需要相应地修改代码: ```python import gradio as gr def create_calback(net_g: SynthesizerTrn, tts_front: VITS_PinYin): def tts_calback(text, dur_scale): if limitation: text_len = len(re.sub("\[([A-Z]{2})\]", "", text)) max_len = 150 if text_len > max_len: return "错误:文本太长[限定150字]", None phonemes, char_embeds = tts_front.chinese_to_phonemes(text) input_ids = cleaned_text_to_sequence(phonemes) with torch.no_grad(): x_tst = torch.LongTensor(input_ids).unsqueeze(0).to(device) x_tst_lengths = torch.LongTensor([len(input_ids)]).to(device) x_tst_prosody = torch.FloatTensor( char_embeds).unsqueeze(0).to(device) audio = net_g.infer(x_tst, x_tst_lengths, x_tst_prosody, noise_scale=0.5, length_scale=dur_scale)[0][0, 0].data.cpu().float().numpy() del x_tst, x_tst_lengths, x_tst_prosody # 修改下载文件的默认存放位置 output_filepath = "/path/to/output/file.wav" # 指定下载文件的存放路径 return "成功", gr.outputs.FileDownload(output_filepath, mime_type="audio/wav") return tts_calback ``` 请确保在代码中添加了 `import gradio as gr`,并使用 `gr.outputs.FileDownload` 来创建下载文件的输出。 非常抱歉给您带来的困惑,希望这次修改能够解决问题。如有任何其他问题,请随时提问!

Traceback (most recent call last): File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\routes.py", line 442, in run_predict output = await app.get_blocks().process_api( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1389, in process_api result = await self.call_function( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1094, in call_function prediction = await anyio.to_thread.run_sync( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run result = context.run(func, *args) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\utils.py", line 703, in wrapper response = f(*args, **kwargs) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\vits_chinese-2.0\app.py", line 66, in tts_calback return "成功", gr.components.File(output_filepath) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\file.py", line 111, in __init__ IOComponent.__init__( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 182, in __init__ else self.postprocess(initial_value) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\file.py", line 250, in postprocess "name": self.make_temp_copy_if_needed(y), File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 226, in make_temp_copy_if_needed temp_dir = self.hash_file(file_path) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 190, in hash_file with open(file_path, "rb") as f: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\LY-AI\\Desktop\\AI\\vits_chinese-2.0\\vits_chinese-2.0\\音频输出\\20230722230030.wav'

非常抱歉给您带来的困扰。根据错误信息显示,找不到文件 `C:\\Users\\LY-AI\\Desktop\\AI\\vits_chinese-2.0\\vits_chinese-2.0\\音频输出\\20230722230030.wav`。请确保指定的文件路径是正确的,并且文件确实存在。 您可以检查以下几点: 1. 确保文件路径 `output_filepath` 是正确的,并且该文件存在。可以尝试手动在文件系统中查找该文件。 2. 确保您的代码在保存音频文件之前已经成功生成了音频文件,并将其保存到指定的文件路径。 3. 检查文件路径中是否包含任何特殊字符或空格,这可能导致文件路径无法正确解析。 如果问题仍然存在,请提供更多关于代码和文件操作的详细信息,以便我们更好地帮助您解决问题。

相关推荐

Warning (from warnings module): File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\vits_chinese-2.0\app.py", line 66 return "成功", gr.outputs.File(output_filepath) GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components DEBUG:matplotlib.pyplot:Loaded backend TkAgg version 8.6. Traceback (most recent call last): File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\routes.py", line 442, in run_predict output = await app.get_blocks().process_api( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1392, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1326, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\audio.py", line 334, in postprocess file_path = self.make_temp_copy_if_needed(y) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 226, in make_temp_copy_if_needed temp_dir = self.hash_file(file_path) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 190, in hash_file with open(file_path, "rb") as f: TypeError: expected str, bytes or os.PathLike object, not File

Warning (from warnings module): File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\vits_chinese-2.0\app.py", line 65 return "成功", gr.outputs.File(output_filepath) GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components DEBUG:matplotlib.pyplot:Loaded backend TkAgg version 8.6. Traceback (most recent call last): File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\routes.py", line 442, in run_predict output = await app.get_blocks().process_api( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1392, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1326, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\audio.py", line 334, in postprocess file_path = self.make_temp_copy_if_needed(y) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 226, in make_temp_copy_if_needed temp_dir = self.hash_file(file_path) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 190, in hash_file with open(file_path, "rb") as f: TypeError: expected str, bytes or os.PathLike object, not File

Building prefix dict from the default dictionary ... DEBUG:jieba:Building prefix dict from the default dictionary ... Loading model from cache C:\Users\LY-AI\AppData\Local\Temp\jieba.cache DEBUG:jieba:Loading model from cache C:\Users\LY-AI\AppData\Local\Temp\jieba.cache Loading model cost 0.717 seconds. DEBUG:jieba:Loading model cost 0.717 seconds. Prefix dict has been built successfully. DEBUG:jieba:Prefix dict has been built successfully. C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\python3.9.13\3.9.13\lib\site-packages\gradio\processing_utils.py:183: UserWarning: Trying to convert audio automatically from float32 to 16-bit int format. warnings.warn(warning.format(data.dtype)) Traceback (most recent call last): File "C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\python3.9.13\3.9.13\lib\site-packages\gradio\routes.py", line 442, in run_predict output = await app.get_blocks().process_api( File "C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1392, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1326, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\app.py", line 42, in audio_postprocess return gr_processing_utils.encode_url_or_file_to_base64(data["name"]) AttributeError: module 'gradio.processing_utils' has no attribute 'encode_url_or_file_to_base64'

To create a public link, set share=True in launch(). Building prefix dict from the default dictionary ... DEBUG:jieba:Building prefix dict from the default dictionary ... Loading model from cache C:\Users\LY-AI\AppData\Local\Temp\jieba.cache DEBUG:jieba:Loading model from cache C:\Users\LY-AI\AppData\Local\Temp\jieba.cache Loading model cost 0.715 seconds. DEBUG:jieba:Loading model cost 0.715 seconds. Prefix dict has been built successfully. DEBUG:jieba:Prefix dict has been built successfully. C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\python3.9.13\3.9.13\lib\site-packages\gradio\processing_utils.py:183: UserWarning: Trying to convert audio automatically from float32 to 16-bit int format. warnings.warn(warning.format(data.dtype)) Traceback (most recent call last): File "C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\python3.9.13\3.9.13\lib\site-packages\gradio\routes.py", line 442, in run_predict output = await app.get_blocks().process_api( File "C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1392, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1326, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\Users\LY-AI\Desktop\AI\vits-uma-genshin-honkai\app.py", line 41, in audio_postprocess return gr.processing_utils.encode_url_or_file_to_base64(data['name']) AttributeError: module 'gradio.processing_utils' has no attribute 'encode_url_or_file_to_base64'

最新推荐

recommend-type

基于SpringBoot框架的中小企业完全开源的ERP.zip

基于springboot的java毕业&课程设计
recommend-type

基于Springboot的健身信息系统.zip

基于springboot的java毕业&课程设计
recommend-type

基于vue + springboot的学生成绩管理系统.zip

基于springboot的java毕业&课程设计
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

SQL怎么实现 数据透视表

SQL可以通过使用聚合函数和GROUP BY子句来实现数据透视表。 例如,假设有一个销售记录表,其中包含产品名称、销售日期、销售数量和销售额等信息。要创建一个按照产品名称、销售日期和销售额进行汇总的数据透视表,可以使用以下SQL语句: ``` SELECT ProductName, SaleDate, SUM(SaleQuantity) AS TotalQuantity, SUM(SaleAmount) AS TotalAmount FROM Sales GROUP BY ProductName, SaleDate; ``` 该语句将Sales表按照ProductName和SaleDat
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

实现实时监控告警系统:Kafka与Grafana整合

![实现实时监控告警系统:Kafka与Grafana整合](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2pwZy9BVldpY3ladXVDbEZpY1pLWmw2bUVaWXFUcEdLT1VDdkxRSmQxZXB5R1lxaWNlUjA2c0hFek5Qc3FyRktudFF1VDMxQVl3QTRXV2lhSWFRMEFRc0I1cW1ZOGcvNjQw?x-oss-process=image/format,png) # 1.1 Kafka集群架构 Kafka集群由多个称为代理的服务器组成,这