mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 19:02:17 +08:00
修复因空格导致的语音失效问题
This commit is contained in:
parent
b482c8ba99
commit
0667a3ccf5
@ -69,12 +69,9 @@ class MediaMsg:
|
|||||||
buf = self.get_media_buffer(reserved0)
|
buf = self.get_media_buffer(reserved0)
|
||||||
if not buf:
|
if not buf:
|
||||||
return ''
|
return ''
|
||||||
silk_path = f"{output_path}\\{reserved0}.silk"
|
silk_path = f"{output_path}/{reserved0}.silk"
|
||||||
pcm_path = f"{output_path}\\{reserved0}.pcm"
|
pcm_path = f"{output_path}/{reserved0}.pcm"
|
||||||
mp3_path = f"{output_path}\\{reserved0}.mp3"
|
mp3_path = f"{output_path}/{reserved0}.mp3"
|
||||||
silk_path = silk_path.replace("/", "\\")
|
|
||||||
pcm_path = pcm_path.replace("/", "\\")
|
|
||||||
mp3_path = mp3_path.replace("/", "\\")
|
|
||||||
if os.path.exists(mp3_path):
|
if os.path.exists(mp3_path):
|
||||||
return mp3_path
|
return mp3_path
|
||||||
with open(silk_path, "wb") as f:
|
with open(silk_path, "wb") as f:
|
||||||
@ -98,8 +95,8 @@ class MediaMsg:
|
|||||||
print(f"Error: {e}")
|
print(f"Error: {e}")
|
||||||
cmd = f'''{os.path.join(os.getcwd(), 'app', 'resources', 'data', 'ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
|
cmd = f'''{os.path.join(os.getcwd(), 'app', 'resources', 'data', 'ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
|
||||||
system(cmd)
|
system(cmd)
|
||||||
system(f'del {silk_path}')
|
os.remove(silk_path)
|
||||||
system(f'del {pcm_path}')
|
os.remove(pcm_path)
|
||||||
print(mp3_path)
|
print(mp3_path)
|
||||||
return mp3_path
|
return mp3_path
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from PyQt5.QtCore import pyqtSignal, QThread
|
|||||||
from PyQt5.QtWidgets import QFileDialog
|
from PyQt5.QtWidgets import QFileDialog
|
||||||
from docx.oxml.ns import qn
|
from docx.oxml.ns import qn
|
||||||
|
|
||||||
from . import msg_db, micro_msg_db
|
from . import msg_db
|
||||||
from .package_msg import PackageMsg
|
from .package_msg import PackageMsg
|
||||||
from ..DataBase import hard_link_db
|
from ..DataBase import hard_link_db
|
||||||
from ..DataBase import media_msg_db
|
from ..DataBase import media_msg_db
|
||||||
@ -18,7 +18,7 @@ from ..person import MePC
|
|||||||
from ..util import path
|
from ..util import path
|
||||||
import shutil
|
import shutil
|
||||||
from ..util.compress_content import parser_reply
|
from ..util.compress_content import parser_reply
|
||||||
from ..util.emoji import get_emoji, get_emoji_path, get_emoji_url
|
from ..util.emoji import get_emoji_url
|
||||||
from ..util.image import get_image_path, get_image, get_image_abs_path
|
from ..util.image import get_image_path, get_image, get_image_abs_path
|
||||||
from ..util.file import get_file
|
from ..util.file import get_file
|
||||||
import docx
|
import docx
|
||||||
@ -311,8 +311,6 @@ class ChildThread(QThread):
|
|||||||
return
|
return
|
||||||
image_path = image_thumb_path
|
image_path = image_thumb_path
|
||||||
image_path = get_image_path(image_path, base_path=f'/data/聊天记录/{self.contact.remark}/image')
|
image_path = get_image_path(image_path, base_path=f'/data/聊天记录/{self.contact.remark}/image')
|
||||||
image_path = image_path.replace('/', '\\')
|
|
||||||
image_path = image_path.replace('\\', '/')
|
|
||||||
doc.write(
|
doc.write(
|
||||||
f'''{{ type:{type_}, text: '{image_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
f'''{{ type:{type_}, text: '{image_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
||||||
)
|
)
|
||||||
@ -367,8 +365,6 @@ class ChildThread(QThread):
|
|||||||
if self.output_type == Output.HTML:
|
if self.output_type == Output.HTML:
|
||||||
try:
|
try:
|
||||||
audio_path = media_msg_db.get_audio_path(msgSvrId, output_path=origin_docx_path + "/voice")
|
audio_path = media_msg_db.get_audio_path(msgSvrId, output_path=origin_docx_path + "/voice")
|
||||||
audio_path = audio_path.replace('/', '\\')
|
|
||||||
audio_path = audio_path.replace('\\', '/')
|
|
||||||
audio_path = "./voice/" + os.path.basename(audio_path)
|
audio_path = "./voice/" + os.path.basename(audio_path)
|
||||||
voice_to_text = escape_js_and_html(media_msg_db.get_audio_text(str_content))
|
voice_to_text = escape_js_and_html(media_msg_db.get_audio_text(str_content))
|
||||||
except:
|
except:
|
||||||
@ -403,8 +399,6 @@ class ChildThread(QThread):
|
|||||||
displayname = MePC().name if is_send else self.contact.remark
|
displayname = MePC().name if is_send else self.contact.remark
|
||||||
displayname = escape_js_and_html(displayname)
|
displayname = escape_js_and_html(displayname)
|
||||||
if self.output_type == Output.HTML:
|
if self.output_type == Output.HTML:
|
||||||
# emoji_path = get_emoji_path(str_content, thumb=True, output_path=origin_docx_path + '/emoji')
|
|
||||||
# emoji_path = './emoji/' + os.path.basename(emoji_path)
|
|
||||||
emoji_path = get_emoji_url(str_content, thumb=True)
|
emoji_path = get_emoji_url(str_content, thumb=True)
|
||||||
doc.write(
|
doc.write(
|
||||||
f'''{{ type:{3}, text: '{emoji_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
f'''{{ type:{3}, text: '{emoji_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
||||||
@ -428,8 +422,6 @@ class ChildThread(QThread):
|
|||||||
p.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
|
p.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
|
||||||
doc.add_paragraph()
|
doc.add_paragraph()
|
||||||
|
|
||||||
def wx_file(self, doc, isSend, content, status):
|
|
||||||
return
|
|
||||||
|
|
||||||
def file(self, doc, message):
|
def file(self, doc, message):
|
||||||
origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}"
|
origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}"
|
||||||
@ -615,9 +607,6 @@ class ChildThread(QThread):
|
|||||||
# todo 网络图片问题
|
# todo 网络图片问题
|
||||||
print(origin_docx_path + image_path[1:])
|
print(origin_docx_path + image_path[1:])
|
||||||
os.utime(origin_docx_path + image_path[1:], (timestamp, timestamp))
|
os.utime(origin_docx_path + image_path[1:], (timestamp, timestamp))
|
||||||
image_path = image_path.replace('\\', '/')
|
|
||||||
# print(f"tohtml:---{image_path}")
|
|
||||||
|
|
||||||
doc.write(
|
doc.write(
|
||||||
f'''{{ type:3, text: '{image_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
f'''{{ type:3, text: '{image_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
||||||
)
|
)
|
||||||
@ -635,7 +624,6 @@ class ChildThread(QThread):
|
|||||||
shutil.copy(video_path, os.path.join(origin_docx_path, 'video'))
|
shutil.copy(video_path, os.path.join(origin_docx_path, 'video'))
|
||||||
os.utime(new_path, (timestamp, timestamp))
|
os.utime(new_path, (timestamp, timestamp))
|
||||||
video_path = f'./video/{os.path.basename(video_path)}'
|
video_path = f'./video/{os.path.basename(video_path)}'
|
||||||
video_path = video_path.replace('\\', '/')
|
|
||||||
doc.write(
|
doc.write(
|
||||||
f'''{{ type:{type_}, text: '{video_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
f'''{{ type:{type_}, text: '{video_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
||||||
)
|
)
|
||||||
|
@ -60,7 +60,7 @@ class ContactPC:
|
|||||||
self.nickName = contact_info.get('NickName')
|
self.nickName = contact_info.get('NickName')
|
||||||
if not self.remark:
|
if not self.remark:
|
||||||
self.remark = self.nickName
|
self.remark = self.nickName
|
||||||
self.remark = re.sub(r'[\/:*?"<>|]', '_', self.remark)
|
self.remark = re.sub(r'[\/:*?"<>|\s]', '_', self.remark)
|
||||||
self.smallHeadImgUrl = contact_info.get('smallHeadImgUrl')
|
self.smallHeadImgUrl = contact_info.get('smallHeadImgUrl')
|
||||||
self.smallHeadImgBLOG = b''
|
self.smallHeadImgBLOG = b''
|
||||||
self.avatar = QPixmap()
|
self.avatar = QPixmap()
|
||||||
|
Loading…
Reference in New Issue
Block a user