Commit 86a17ba3 authored by zhangzhe's avatar zhangzhe

Merge branch 'branch_1.0.1' of gitlab.huolea.com:lmi/shorthandmaster into branch_1.0.1

parents c9b388a8 1d38dd26
......@@ -111,6 +111,7 @@
A960947524FD25D800121D32 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A960947424FD25D800121D32 /* AVFoundation.framework */; };
A9690667251AE84000E5F604 /* SHRecordFolderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9690666251AE84000E5F604 /* SHRecordFolderModel.swift */; };
A969066C251AFA6700E5F604 /* NSObject+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A969066B251AFA6700E5F604 /* NSObject+Extension.swift */; };
A975B105252097E400EC267C /* SHAVAudioManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A975B104252097E400EC267C /* SHAVAudioManager.swift */; };
A9A16C672519DD6900DE0FEE /* NSString+PinYin4Cocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A16C542519DD6800DE0FEE /* NSString+PinYin4Cocoa.m */; };
A9A16C682519DD6900DE0FEE /* unicode_to_hanyu_pinyin.txt in Resources */ = {isa = PBXBuildFile; fileRef = A9A16C552519DD6800DE0FEE /* unicode_to_hanyu_pinyin.txt */; };
A9A16C692519DD6900DE0FEE /* PinyinHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A16C5A2519DD6800DE0FEE /* PinyinHelper.m */; };
......@@ -299,6 +300,7 @@
A960947424FD25D800121D32 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
A9690666251AE84000E5F604 /* SHRecordFolderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHRecordFolderModel.swift; sourceTree = "<group>"; };
A969066B251AFA6700E5F604 /* NSObject+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+Extension.swift"; sourceTree = "<group>"; };
A975B104252097E400EC267C /* SHAVAudioManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHAVAudioManager.swift; sourceTree = "<group>"; };
A9A16C512519DD6800DE0FEE /* PinyinHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PinyinHelper.h; sourceTree = "<group>"; };
A9A16C522519DD6800DE0FEE /* HanyuPinyinOutputFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HanyuPinyinOutputFormat.h; sourceTree = "<group>"; };
A9A16C532519DD6800DE0FEE /* ChineseInclude.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChineseInclude.h; sourceTree = "<group>"; };
......@@ -750,6 +752,7 @@
A950F5AB24F39EC1007AB63E /* SHRecordShowViewController.swift */,
A94EE11C251B7E510066B490 /* SHRecordDetailsVC.swift */,
A924A85F251C777E00CB2947 /* SHRecordMoveFileVC.swift */,
A975B104252097E400EC267C /* SHAVAudioManager.swift */,
);
path = Record;
sourceTree = "<group>";
......@@ -1125,6 +1128,7 @@
A9A16C6B2519DD6900DE0FEE /* HanyuPinyinOutputFormat.m in Sources */,
A95CDFC124E0EBF10066DAE6 /* UIButton+Extension.swift in Sources */,
A9A16C6C2519DD6900DE0FEE /* ZYPinYinSearch.m in Sources */,
A975B105252097E400EC267C /* SHAVAudioManager.swift in Sources */,
A94D935B24F7977400A886C0 /* PhoneSystemKit.swift in Sources */,
A94DD57624FDFB4700B1B5A2 /* ExtAudioFileMixer.m in Sources */,
A95CDFDC24E0EBF10066DAE6 /* CRConstants.swift in Sources */,
......
......@@ -19,7 +19,7 @@ class SHInputController: SHBaseViewController
var saveSuccessCallBack:((SHRecordFolderModel)->Void)?
/// 存储数据的model
private var dataModel: SHRecordModel = SHRecordModel()
var dataModel: SHRecordModel = SHRecordModel()
/// 未填写标题时的默认标题
private let defaultTitle: String = "新建笔记"
......
......@@ -365,35 +365,35 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ace-iU-keq">
<rect key="frame" x="50" y="5" width="344" height="220"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6bV-3V-R81">
<rect key="frame" x="18" y="18" width="44" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6bV-3V-R81">
<rect key="frame" x="18" y="18" width="44" height="21.5"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" red="0.0" green="0.074509803921568626" blue="0.23921568627450979" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FVv-OG-DwV">
<rect key="frame" x="18" y="80" width="35.5" height="17"/>
<rect key="frame" x="18" y="80.5" width="35.5" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="recordDetails_voice" translatesAutoresizingMaskIntoConstraints="NO" id="6je-jR-opG">
<rect key="frame" x="18" y="107" width="16" height="16"/>
<rect key="frame" x="18" y="107.5" width="16" height="16"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XAw-V9-smq">
<rect key="frame" x="39" y="106.5" width="36" height="17"/>
<rect key="frame" x="39" y="107" width="36" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.58431372549019611" green="0.62745098039215685" blue="0.72156862745098038" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cAa-wI-k0B">
<rect key="frame" x="18" y="49" width="36" height="17"/>
<rect key="frame" x="18" y="49.5" width="36" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.58431372549019611" green="0.62745098039215685" blue="0.72156862745098038" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SzJ-Gk-Tag">
<rect key="frame" x="296" y="100" width="30" height="30"/>
<rect key="frame" x="296" y="100.5" width="30" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="30" id="oaj-sd-4Uh"/>
<constraint firstAttribute="height" constant="30" id="wkj-jD-iI1"/>
......@@ -418,6 +418,7 @@
<constraint firstItem="6bV-3V-R81" firstAttribute="top" secondItem="Ace-iU-keq" secondAttribute="top" constant="18" id="Sj5-yA-Hdn"/>
<constraint firstItem="FVv-OG-DwV" firstAttribute="leading" secondItem="6bV-3V-R81" secondAttribute="leading" id="k4e-UV-52H"/>
<constraint firstItem="cAa-wI-k0B" firstAttribute="top" secondItem="6bV-3V-R81" secondAttribute="bottom" constant="10" id="mde-3T-2mf"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6bV-3V-R81" secondAttribute="trailing" constant="18" id="xug-bT-eC2"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="adA-MF-vWU">
......
//
// SHAVAudioManager.swift
// ShorthandMaster
//
// Created by 明津李 on 2020/9/27.
// Copyright © 2020 明津李. All rights reserved.
//
import UIKit
import AVFoundation
import Speech
class SHAVAudioManager: NSObject, SFSpeechRecognizerDelegate {
@objc static let shared = SHAVAudioManager()
private override init() {}
// 创建语音识别器,指定语音识别的语言环境 locale ,将来会转化为什么语言,这里是使用的当前区域,那肯定就是简体汉语啦
// private let speechRecognizer = SFSpeechRecognizer(locale: Locale.autoupdatingCurrent)
private let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "zh-CN"))
// url : 录音文件的路径
var monitor_file_path = DocumentPath.appending("/monitor.wav")
var session: AVAudioSession {
let session:AVAudioSession = AVAudioSession.sharedInstance()
do {
try session.setCategory(AVAudioSession.Category.playAndRecord, options: .defaultToSpeaker)
}catch{
print("session config failed")
}
return session
}
// 发起语音识别请求,为语音识别器指定一个音频输入源,这里是在音频缓冲器中提供的识别语音。
private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest?
// 语音识别任务,可监控识别进度。通过他可以取消或终止当前的语音识别任务
private var recognitionTask: SFSpeechRecognitionTask?
// 语音引擎,负责提供录音输入
private var audioEngine = AVAudioEngine()
// 文本数据
private var recognitionTaskText: [String] = []
lazy var monitor: AVAudioRecorder? = self.getRecorder(monitor_file_path)
private func getRecorder(_ path:String) -> AVAudioRecorder?{
// setting : 录音的设置项
// 录音参数设置(不需要掌握, 一些固定的配置)
let configDic: [String: AnyObject] = [
// 编码格式
AVFormatIDKey: NSNumber(value: Int32(kAudioFormatLinearPCM)),
// 采样率
AVSampleRateKey: NSNumber(value: 14400.0),
//采样位数
AVLinearPCMBitDepthKey: NSNumber(value: 16),
// 通道数
AVNumberOfChannelsKey: NSNumber(value: 2),
// 录音质量
AVEncoderAudioQualityKey: NSNumber(value: Int32(AVAudioQuality.max.rawValue))
]
do {
let recorder = try AVAudioRecorder(url: URL(fileURLWithPath: path), settings: configDic)
recorder.isMeteringEnabled = true
// 准备录音(系统会给我们分配一些资源)
recorder.prepareToRecord()
return recorder
}catch {
print(error)
return nil
}
}
private var recorderTimer: SHTimer?
var resultTxts: [String] = []
private func configRecorder(){
speechRecognizer?.delegate = self
AVAudioSession.sharedInstance().requestRecordPermission { (allowed) in
if !allowed {
return
}
}
let session:AVAudioSession = AVAudioSession.sharedInstance()
do {
try session.setCategory(AVAudioSession.Category.playAndRecord, options: .defaultToSpeaker)
}catch{
print("session config failed")
}
do { try AVAudioSession.sharedInstance().setActive(true) }
catch { print("session active failed") }
}
private func configSpeechTask(){
audioEngine = AVAudioEngine()
// 初始化RecognitionRequest,在后边我们会用它将录音数据转发给苹果服务器
recognitionRequest = SFSpeechAudioBufferRecognitionRequest()
// 在用户说话的同时,将识别结果分批次返回
recognitionRequest?.shouldReportPartialResults = true
// 使用recognitionTask方法开始识别。
recognitionTask = speechRecognizer?.recognitionTask(with: recognitionRequest!, resultHandler: { (result, error) in
// 用于检查识别是否结束
var isFinal = false
// 如果 result 不是 nil,
var ss = ""
if result != nil {
ss = result?.bestTranscription.formattedString ?? ""
print("result?.bestTranscription.formattedString ==== \(ss)")
// 如果 result 是最终,将 isFinal 设置为 true
isFinal = (result?.isFinal)!
}
// 如果没有错误发生,或者 result 已经结束,停止audioEngine 录音,终止 recognitionRequest 和 recognitionTask
if error != nil || isFinal {
if ss.length > 0 {
self.resultTxts.append(ss)
print("self.resultTxts ==== \(self.resultTxts)")
}
}
})
// 向recognitionRequest加入一个音频输入
let recordingFormat = audioEngine.inputNode.outputFormat(forBus: 0)
audioEngine.inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer, when) in
self.recognitionRequest?.append(buffer)
}
self.audioEngine.prepare()
do {
// 开始录音
try audioEngine.start()
} catch {
print("audioEngine couldn't start because of an error.")
}
}
@objc private func updateMeters() {
self.monitor?.updateMeters()
// 获得0声道的音量,完全没有声音-160.0,0是最大音量
let decibels = (self.monitor?.peakPower(forChannel: 0))!
print("decibels == \(decibels)")
if decibels > -24 {
}else{
// recorderTimer?.invalidate()
// audioEngine.stop()
// recognitionRequest = nil
recognitionTask = nil
recorderDataSourceHandler()
}
}
func recorderDataSourceHandler(){
// start()
// recorderTimer?.invalidate()
// monitor?.stop()
// monitor?.deleteRecording()
// recorder?.stop()
// recorder?.deleteRecording()
}
func start(){
self.configRecorder()
self.configSpeechTask()
// self.recorder?.record()
self.monitor?.record()
recorderTimer = SHTimer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(updateMeters), userInfo: nil, repeats: true)
}
func pause(){
// monitor?.stop()
// monitor?.deleteRecording()
// recorder?.stop()
// recorder?.deleteRecording()
}
func stop(){
// monitor?.stop()
// monitor?.deleteRecording()
// recorder?.stop()
// recorder?.deleteRecording()
recorderTimer?.invalidate()
}
}
......@@ -25,6 +25,7 @@ class SHRecordDetailsVC: SHBaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
updateocloudUI()
}
......@@ -88,6 +89,19 @@ class SHRecordDetailsVC: SHBaseViewController {
//MARK:XXXXXXXXX
func updateocloudUI(_ update: Bool = true){
switch CRUserDefaults.sortType {
case 0:
currentModel.dataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
break
default:
currentModel.dataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
break
}
for recordModel in self.currentModel.dataSources {
recordModel.icloud = false
}
......@@ -283,23 +297,7 @@ extension SHRecordDetailsVC {
self.updateocloudUI()
}
}
// list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
// if var recordList = list{
// for (index, subDict) in recordList.enumerated(){
// let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
// if subFolderModel.id == currentModel.id {
// subFolderModel.modifyDate = nowDate
// subFolderModel.dataSources = currentModel.dataSources
// let dic = getDictWith(obj: subFolderModel)
// recordList[index] = dic
// break
// }
// }
// keyValueStore.set(recordList, forKey: "Folderlist")
// keyValueStore.synchronize()
// }
if currentModel.dataSources.count == 0 {
self.editClick(true)
self.markAlertViewShow(false)
......@@ -395,8 +393,19 @@ extension SHRecordDetailsVC: UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let show = UIStoryboard.init(name: "Record", bundle: nil).instantiateViewController(withIdentifier: "SHRecordShowViewController") as! SHRecordShowViewController
show.model = currentModel.dataSources[indexPath.row]
self.navigationController?.pushViewController(show, animated: true)
// let show = UIStoryboard.init(name: "Record", bundle: nil).instantiateViewController(withIdentifier: "SHRecordShowViewController") as! SHRecordShowViewController
// show.model = currentModel.dataSources[indexPath.row]
// self.navigationController?.pushViewController(show, animated: true)
let input = SHInputController.init()
input.folderModel = currentModel
input.dataModel = currentModel.dataSources[indexPath.row]
self.navigationController?.pushViewController(input, animated: true)
input.saveSuccessCallBack = { model in
self.currentModel = model
self.updateocloudUI()
}
}
}
......@@ -56,6 +56,8 @@ class SHRecordListViewController: SHBaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
// SHAVAudioManager.shared.start()
let url = FileManager.default.url(forUbiquityContainerIdentifier: nil)
print(url as Any)
......
......@@ -83,50 +83,20 @@ class SHRecordMoveFileVC: SHBaseViewController {
}
}
}
var list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
if list == nil {
list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
}
list = nil
if list != nil {
for dict in list!.reversed(){
var model = SHRecordFolderModel()
model = getDataDictWith(dict: dict)
if model.id != currentModel.id {
dataSources.append(model)
}
switch CRUserDefaults.sortType {
case 0:
dataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
dataSources = dataSources.filterDuplicates({$0.id})
switch CRUserDefaults.sortType {
case 0:
dataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
break
default:
dataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
break
}
}else{
switch CRUserDefaults.sortType {
case 0:
dataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
break
default:
dataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
break
break
default:
dataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
break
}
tableView?.reloadData()
}
......@@ -157,19 +127,7 @@ class SHRecordMoveFileVC: SHBaseViewController {
let list = [modelDict]
CRUserDefaults.recordList = list
}
// let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
//
// if var list = list {
// list.append(modelDict)
// self.keyValueStore.set(list, forKey: "Folderlist")
// self.keyValueStore.synchronize()
// }else{
// let list = [modelDict]
// self.keyValueStore.set(list, forKey: "Folderlist")
// self.keyValueStore.synchronize()
// }
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) {
self.prepareDataSource()
}
......@@ -253,34 +211,6 @@ class SHRecordMoveFileVC: SHBaseViewController {
}
}
}
// list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
// if var recordList = list{
// //增
// for (index, subDict) in recordList.enumerated(){
// let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
// if subFolderModel.id == targetModel.id {
// subFolderModel.modifyDate = nowDate
// subFolderModel.dataSources = subFolderModel.dataSources+moveFiles
// let dic = getDictWith(obj: subFolderModel)
// recordList[index] = dic
// break
// }
// }
// //删
// for (index, subDict) in recordList.enumerated(){
// let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
// if subFolderModel.id == currentModel.id {
// subFolderModel.modifyDate = nowDate
// subFolderModel.dataSources = currentModel.dataSources
// let dic = getDictWith(obj: subFolderModel)
// recordList[index] = dic
// break
// }
// }
// keyValueStore.set(recordList, forKey: "Folderlist")
// keyValueStore.synchronize()
// }
}
}
......
......@@ -44,16 +44,16 @@ class SHRecordViewController: SHBaseViewController{
private let soundMeterCount = 50 /// 录音时间
private var recordTime = 0.00
// url : 录音文件的路径
// mp3_url : 录音文件的路径
var wav_file_path = DocumentPath.appending("/record.wav")
var mp3_file_path = DocumentPath.appending("/record.mp3")
var pcm_file_path = DocumentPath.appending("/xbMixData.caf")
var mp3_file_path = ""
var pcm_file_path = ""
var image_file_path = ""
var image_file_paths: [String] = []
var image_indexs: [NSInteger] = []
var session:AVAudioSession {
var session: AVAudioSession {
let session:AVAudioSession = AVAudioSession.sharedInstance()
do {
try session.setCategory(AVAudioSession.Category.playAndRecord, options: .defaultToSpeaker)
......@@ -62,8 +62,7 @@ class SHRecordViewController: SHBaseViewController{
}
return session
}
var player: AVAudioPlayer?
lazy var recorder: AVAudioRecorder? = self.getRecorder()
var recorder_mp3: SHMp3RecordManager = SHMp3RecordManager.shared()
......@@ -111,8 +110,6 @@ class SHRecordViewController: SHBaseViewController{
self.view.bringSubviewToFront(maskView)
self.view.bringSubviewToFront(recorderBtn)
// self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(image: UIImage.init(named: "record_nav_user"), style: .plain, target: self, action: #selector(userCilck))
self.view.layoutIfNeeded()
self.view.layoutSubviews()
......@@ -373,7 +370,7 @@ class SHRecordViewController: SHBaseViewController{
private func configRecorder(){
//分贝线初始
waveView.remake()
// waveView.remake()
//音频容器初始
soundMeters = [Float]()
......@@ -409,6 +406,11 @@ class SHRecordViewController: SHBaseViewController{
if result != nil {
// 将 textView.text 设置为 result 的最佳音译
self.currentTxt = result?.bestTranscription.formattedString
print("result?.bestTranscription.formattedString ==== \(result!.bestTranscription.formattedString)")
print("result?.transcriptions ==== \(result!.transcriptions)")
print("result?.first.formattedString ==== \(result!.transcriptions.first!.formattedString)")
if self.recognitionTaskText.count == 0 {
self.recordTextView.attributedText = self.textView_text(result?.bestTranscription.formattedString ?? "")
}else{
......
......@@ -30,7 +30,19 @@ class SHRecordDetailsCell: UITableViewCell {
titleName?.text = newValue.rename
timeLab?.text = Date.getShortTimeByStamp_record(timestamp: Int64(newValue.modifyDate.timeIntervalSince1970))
txtLab?.text = newValue.txt
if model.recordingType == 1 {
let txts = newValue.txt.components(separatedBy: "\n")
let result = txts.reduce("" , { x, y in
if x.length == 0{
return x + y
}else{
return x + "\n" + y
}
})
txtLab?.text = result
}else{
txtLab?.text = newValue.txt
}
duringLab?.text = countSecond(newValue.during)
selectedBtn?.isSelected = model.selected
icloudBtn?.isSelected = model.icloud
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment