You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

975 lines
26 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

1.对话式大模型
@startuml
title Minote Iflytek LLM Interaction
skinparam sequenceParticipant underline
skinparam stereotypePosition top
hide footbox
actor user
participant NoteEditActivity<<Boundary>>
participant IflytekActivity<<Control>>
participant SparkChain<<Entity>>
participant LLMFactory<<Entity>>
participant chat_llm<<Entity>>
participant mCallback<<Entity>>
note right of user: 用户启动应用
user -> NoteEditActivity : 启动LLM
activate NoteEditActivity
NoteEditActivity -> IflytekActivity : 初始化SDK
activate IflytekActivity
IflytekActivity -> SparkChain : init(Config)
activate SparkChain
SparkChain --> IflytekActivity : 初始化完成
deactivate SparkChain
IflytekActivity -> LLMFactory : textGeneration()
activate LLMFactory
LLMFactory --> chat_llm : 创建LLM实例
deactivate LLMFactory
IflytekActivity -> chat_llm : 注册回调\n注册LLMCallbacks
activate chat_llm
chat_llm -> mCallback : registerLLMCallbacks(mCallback)
deactivate chat_llm
alt 同步模式
IflytekActivity -> chat_llm : run(question)
activate chat_llm
chat_llm --> IflytekActivity : syncOutput
deactivate chat_llm
loop 循环获取结果
IflytekActivity -> mCallback : syncOutput.getContent()
mCallback --> IflytekActivity : result
end
else 异步模式
IflytekActivity -> chat_llm : arun(question)
activate chat_llm
loop 等待回调
mCallback -> chat_llm : 接收结果
chat_llm -> mCallback : getContent()
mCallback -> IflytekActivity : 处理结果
end
end
IflytekActivity -> NoteEditActivity : 展示结果
deactivate IflytekActivity
NoteEditActivity --> user : 展示结果
deactivate NoteEditActivity
user -> NoteEditActivity : 退出应用
activate NoteEditActivity
NoteEditActivity -> IflytekActivity : 停止LLM
activate IflytekActivity
IflytekActivity -> SparkChain : uninit()
activate SparkChain
SparkChain --> IflytekActivity : 逆初始化完成
deactivate SparkChain
IflytekActivity --> NoteEditActivity : 通知退出完成
deactivate IflytekActivity
NoteEditActivity --> user : 通知退出完成
deactivate NoteEditActivity
@enduml
2.语音听写
@startuml
title Minote Iflytek Iat
skinparam sequenceParticipant underline
skinparam stereotypePosition top
hide footbox
actor User as user
participant "NoteEditActivity" as note<<Boundary>>
participant "IatDemo" as demo<<Control>>
participant "SpeechRecognizer" as recognizer<<Entity>>
participant "RecognizerDialog" as dialog<<Entity>>
participant "JsonParser" as parser<<Entity>>
participant "SpeechUtility" as utility<<Entity>>
activate user
== 初始化阶段 ==
user -> note : 点击语音按钮
activate note
note -> demo : startActivity()
deactivate note
activate demo
demo -> utility : createUtility(appid)
activate utility
demo -> recognizer : createRecognizer(InitListener)
activate recognizer
demo -> dialog : new RecognizerDialog(InitListener)
activate dialog
== 参数配置阶段 ==
user -> demo : 点击开始听写
demo -> recognizer : setParameter(LANGUAGE, "zh_cn")
demo -> recognizer : setParameter(VAD_BOS, "4000")
demo -> recognizer : setParameter(VAD_EOS, "1000")
== 语音识别阶段 ==
demo -> dialog : show()
deactivate demo
dialog -->> user : 显示录音对话框
user -> dialog : 开始说话
dialog -->> user : onBeginOfSpeech()显示"开始说话"
loop 语音输入过程
dialog -->> user : onVolumeChanged()显示音量大小
end
user -> dialog : 停止说话
dialog -->> user : onEndOfSpeech()显示"结束说话"
== 结果处理阶段 ==
dialog -> recognizer : 语音数据处理
activate recognizer
recognizer -->> dialog : onResult(RecognizerResult)
deactivate recognizer
dialog -> parser : parseIatResult(json)
activate parser
parser -->> dialog : 返回解析后的文本
deactivate parser
deactivate dialog
activate demo
demo -->> user : 显示识别结果
== 错误处理 ==
alt 识别出错
demo -->> user : 显示错误信息
end
== 完成阶段 ==
user -> demo : 确认文本
demo -->> note : 返回识别文本
deactivate demo
activate note
note -->> user : 更新便签内容
deactivate note
deactivate user
@enduml
3.语音合成
@startuml
title Minote Iflytek Tts
skinparam sequenceParticipant underline
skinparam stereotypePosition top
hide footbox
actor User as user
participant "NoteEditActivity" as note<<Boundary>>
participant "TtsDemo" as demo<<Control>>
participant "SpeechSynthesizer" as synthesizer<<Entity>>
participant "TtsSettings" as settings<<Entity>>
participant "SpeechUtility" as utility<<Entity>>
activate user
== 初始化阶段 ==
user -> note : 点击语音合成按钮
activate note
note -> demo : startActivity()
deactivate note
activate demo
demo -> utility : createUtility(appid)
activate utility
demo -> synthesizer : createSynthesizer(InitListener)
synthesizer -->> demo : onInit()回调初始化状态
== 参数配置阶段 ==
user -> demo : 点击设置按钮
demo -> settings : startActivity()
activate settings
settings -->> user : 显示设置界面(语速/音调/音量)
user -> settings : 调整参数
settings -->> demo : 保存设置参数
deactivate settings
user -> demo : 选择发音人
demo -->> user : 显示发音人列表对话框
user -> demo : 确认发音人选择
== 合成播放阶段 ==
user -> demo : 点击开始播放
demo -> demo : setParam()
demo -> synthesizer : startSpeaking(text, listener)
activate synthesizer
synthesizer -->> demo : onSpeakBegin()
synthesizer -->> user : 开始播放提示
loop 合成播放过程
synthesizer -->> demo : onBufferProgress()
synthesizer -->> demo : onSpeakProgress()
demo -->> user : 显示进度和高亮文本
end
alt 用户控制
user -> demo : 点击暂停
demo -> synthesizer : pauseSpeaking()
synthesizer -->> user : 暂停播放提示
user -> demo : 点击继续
demo -> synthesizer : resumeSpeaking()
synthesizer -->> user : 继续播放提示
user -> demo : 点击停止
demo -> synthesizer : stopSpeaking()
synthesizer -->> user : 停止播放提示
end
synthesizer -->> demo : onCompleted()
deactivate synthesizer
demo -->> user : 播放完成提示
== 结束阶段 ==
user -> demo : 退出界面
demo -> synthesizer : destroy()
deactivate demo
deactivate user
@enduml
4.百度翻译顺序图:
@startuml
title Minote BaiDuTranslate
skinparam sequenceParticipant underline
skinparam stereotypePosition top
hide footbox
actor User as user
participant "NoteEditActivity" as translate<<Control>>
participant "BaiduTranslateService" as service<<Entity>>
participant "MD5Utils" as md5<<Entity>>
participant "RespondBean" as bean<<Entity>>
participant "Retrofit" as retrofit<<Entity>>
activate user
== 初始化阶段 ==
user -> translate : 输入待翻译文本
activate translate
== 参数准备阶段 ==
translate -> translate : 生成随机数salt
translate -> translate : 准备appid
translate -> md5 : getMD5Code(appid + q + salt + 密钥)
activate md5
md5 -->> translate : 返回sign签名
deactivate md5
== 翻译请求阶段 ==
translate -> service : translate(q, from, to, appid, salt, sign)
activate service
service -> retrofit : 发起POST请求
activate retrofit
retrofit -->> service : 返回JSON响应
deactivate retrofit
service -> bean : 解析JSON响应
activate bean
bean -->> service : 返回RespondBean对象
deactivate bean
service -->> translate : 返回翻译结果
deactivate service
== 结果显示阶段 ==
translate -> translate : 处理翻译结果
translate -->> user : 显示翻译结果
alt 翻译出错
translate -->> user : 显示错误信息
end
deactivate translate
deactivate user
@enduml
5.登陆界面顺序图
@startuml
title Minote Iflytek Tts
skinparam sequenceParticipant underline
skinparam stereotypePosition top
hide footbox
actor User as user
participant "LoginActivity" as login<<Boundary>>
participant "SplashActivity" as splash<<Entity>>
participant "NotesListActivity" as list<<Control>>
participant "SetPassword" as setpwd<<Boundary>>
participant "DeletePassword" as delpwd<<Boundary>>
participant "SharedPreferences" as prefs<<Entity>>
activate user
== 应用启动流程 ==
user -> login : 启动应用
activate login
login -> prefs : getBoolean("user")
activate prefs
prefs -->> login : 返回密码设置状态
deactivate prefs
alt 未设置密码
login -> splash : startActivity()
activate splash
splash -> list : 延时3秒后跳转
deactivate splash
activate list
else 已设置密码
login -->> user : 显示登录界面
user -> login : 输入密码
login -> prefs : getString("password")
activate prefs
prefs -->> login : 返回存储的密码
deactivate prefs
alt 密码正确
login -> splash : startActivity()
activate splash
splash -> list : 延时3秒后跳转
deactivate splash
else 密码错误
login -->> user : 显示"密码错误"提示
login -->> user : 清空密码输入框
end
end
deactivate login
== 设置密码流程 ==
user -> list : 选择设置密码
list -> setpwd : startActivity()
activate setpwd
setpwd -->> user : 显示密码设置界面
user -> setpwd : 输入密码和确认密码
alt 密码为空
setpwd -->> user : 显示"密码不能为空"提示
else 两次密码不匹配
setpwd -->> user : 显示"密码不匹配"提示
setpwd -->> user : 清空确认密码框
else 密码设置成功
setpwd -> prefs : putBoolean("user", true)
setpwd -> prefs : putString("password", pwd)
activate prefs
prefs -->> setpwd : 保存成功
deactivate prefs
setpwd -->> user : 显示"设置密码成功"提示
setpwd -->> list : startActivity()
end
deactivate setpwd
== 删除密码流程 ==
user -> list : 选择删除密码
list -> delpwd : startActivity()
activate delpwd
delpwd -->> user : 显示密码验证界面
user -> delpwd : 输入当前密码
alt 密码为空
delpwd -->> user : 显示"密码不能为空"提示
else 密码错误
delpwd -->> user : 显示"密码错误"提示
delpwd -->> user : 清空密码输入框
else 密码正确
delpwd -> prefs : putBoolean("user", false)
activate prefs
delpwd -> prefs : putString("password", "")
prefs -->> delpwd : 保存成功
deactivate prefs
delpwd -->> user : 显示"已经删除登录密码"提示
delpwd -->> list : startActivity()
end
deactivate delpwd
deactivate user
@enduml
6.插入图片顺序图
@startuml
title Minote Insert Image Sequence
skinparam sequenceParticipant underline
hide footbox
actor User
participant NoteEditActivity<<boundary>>
participant ImagePicker<<control>>
participant ContentResolver<<Entity>>
participant NoteEditor<<Entity>>
User -> NoteEditActivity: clickImageButton
activate NoteEditActivity
activate User
NoteEditActivity -> ImagePicker: startActivityForResult(loadImage, PHOTO_REQUEST)
activate ImagePicker
ImagePicker --> User: displayImageSelector
User -> ImagePicker: selectImage
ImagePicker --> NoteEditActivity: returnImageUri
deactivate ImagePicker
NoteEditActivity -> ContentResolver: requestStoragePermission()
activate ContentResolver
ContentResolver --> NoteEditActivity: grantPermission
deactivate ContentResolver
NoteEditActivity -> ContentResolver: getImagePath()
activate ContentResolver
ContentResolver --> NoteEditActivity: returnImagePath
deactivate ContentResolver
NoteEditActivity -> NoteEditor: insertImageToEditor
activate NoteEditor
NoteEditor -> NoteEditor: convertToImage()
NoteEditor --> NoteEditActivity: completeInsertion
deactivate NoteEditor
NoteEditActivity --> User: displayInsertedImage
deactivate NoteEditActivity
@enduml
6.字符数统计
@startuml
title Minote Character Count Sequence
skinparam sequenceParticipant underline
hide footbox
actor User
participant NoteEditActivity<<Boundary>>
participant NoteEditor<<Control>>
participant WorkingNote<<Entity>>
User -> NoteEditActivity: editText()
activate User
activate NoteEditActivity
NoteEditActivity -> NoteEditor: addTextChangedListener(textWatcher)
activate NoteEditor
NoteEditor -> NoteEditor: beforeTextChanged(text:CharSequence, start:int, count:int, after:int)
NoteEditor -> NoteEditor: onTextChanged(text:CharSequence, start:int, before:int, count:int)
NoteEditor -> NoteEditor: afterTextChanged(editable:Editable)
NoteEditor -> WorkingNote: getWorkingText()
activate WorkingNote
WorkingNote -> WorkingNote: getText():String
WorkingNote --> NoteEditor: returnText
deactivate WorkingNote
NoteEditor --> NoteEditActivity: textChangeComplete
deactivate NoteEditor
NoteEditActivity --> User: showCharacterCount
deactivate NoteEditActivity
@enduml
7.富文本
@startuml
title Minote Rich Text Formatting Sequence
skinparam sequenceParticipant underline
hide footbox
actor User
participant NoteEditText<<Control>>
participant PopupWindow<<Entity>>
participant SpannableString<<Entity>>
participant StyleSpan<<Entity>>
User -> NoteEditText: selectText(start:int, end:int)
activate NoteEditText
activate User
NoteEditText -> NoteEditText: showFormatToolbar()
activate PopupWindow
NoteEditText -> PopupWindow: initFormatToolbar(context:Context, layout:int)
PopupWindow --> NoteEditText: toolbarCreated
deactivate PopupWindow
User -> NoteEditText: clickStyleButton(styleType:int)
NoteEditText -> NoteEditText: applyStyle(style:int)
NoteEditText -> NoteEditText: getSelectionStart
NoteEditText -> NoteEditText: getSelectionEnd
NoteEditText -> NoteEditText: getText(Spannable)
alt style == STYLE_BOLD
NoteEditText -> StyleSpan: new StyleSpan(Typeface.BOLD)
activate StyleSpan
NoteEditText -> SpannableString: setSpan(span:StyleSpan, start:int, end:int, flags:int)
activate SpannableString
SpannableString --> NoteEditText: spanApplied
deactivate SpannableString
deactivate StyleSpan
else style == STYLE_HIGHLIGHT
NoteEditText -> SpannableString: new BackgroundColorSpan(Color.YELLOW)
activate SpannableString
NoteEditText -> SpannableString: setSpan(span:BackgroundColorSpan, start:int, end:int, flags:int)
SpannableString --> NoteEditText: spanApplied
deactivate SpannableString
else style == STYLE_ITALIC
NoteEditText -> StyleSpan: new StyleSpan(Typeface.ITALIC)
activate StyleSpan
NoteEditText -> SpannableString: setSpan(span:StyleSpan, start:int, end:int, flags:int)
activate SpannableString
SpannableString --> NoteEditText: spanApplied
deactivate SpannableString
deactivate StyleSpan
end
NoteEditText -> NoteEditText: invalidate()
NoteEditText --> User: displayFormattedText
deactivate NoteEditText
@enduml
8.朗读
@startuml
title Minote TTS (Text-to-Speech) Sequence
skinparam sequenceParticipant underline
hide footbox
actor User
participant NoteEditActivity<<Boundary>>
participant SpeechSynthesizer<<Entity>>
participant TtsListener<<Entity>>
participant NoteEditor<<Entity>>
User -> NoteEditActivity: startTtsButton
activate User
activate NoteEditActivity
NoteEditActivity -> SpeechSynthesizer: createSynthesizer(context:Context, initListener:InitListener)
activate SpeechSynthesizer
SpeechSynthesizer --> NoteEditActivity: returnTtsInstance
deactivate SpeechSynthesizer
User -> NoteEditActivity: clickTtsButton()
NoteEditActivity -> NoteEditor: getText():String
activate NoteEditor
NoteEditor --> NoteEditActivity: returnText
deactivate NoteEditor
NoteEditActivity -> SpeechSynthesizer: setParameter(VOICE_NAME, "xiaoyan")
activate SpeechSynthesizer
NoteEditActivity -> SpeechSynthesizer: setParameter(SPEED, "50")
NoteEditActivity -> SpeechSynthesizer: setParameter(VOLUME, "80")
NoteEditActivity -> SpeechSynthesizer: setParameter(ENGINE_TYPE, TYPE_CLOUD)
NoteEditActivity -> SpeechSynthesizer: startSpeaking(text:String, listener:TtsListener)
SpeechSynthesizer -> TtsListener: onSpeakBegin()
activate TtsListener
alt success
SpeechSynthesizer -> TtsListener: onSpeakProgress(percent:int, beginPos:int, endPos:int)
TtsListener --> User: playingAudio
SpeechSynthesizer -> TtsListener: onCompleted(error:SpeechError)
else error
SpeechSynthesizer -> NoteEditActivity: returnErrorCode
NoteEditActivity --> User: showTip("语音合成失败")
end
TtsListener --> SpeechSynthesizer: speakingComplete
deactivate TtsListener
SpeechSynthesizer --> NoteEditActivity: synthesisComplete
deactivate SpeechSynthesizer
User -> NoteEditActivity: clickStopButton()
NoteEditActivity -> SpeechSynthesizer: stopSpeaking()
activate SpeechSynthesizer
SpeechSynthesizer --> NoteEditActivity: stoppedSpeaking
deactivate SpeechSynthesizer
NoteEditActivity --> User: ttsComplete
deactivate NoteEditActivity
deactivate User
@enduml
9.私密模式
@startuml
title Minote Private Mode Content Masking Sequence
skinparam sequenceParticipant underline
hide footbox
actor User
participant "NotesListActivity" as NotesListActivity <<boundary>>
participant "NotesListAdapter" as NotesListAdapter <<control>>
participant "NoteItemData" as NoteItemData <<entity>>
participant "WorkingNote" as WorkingNote <<entity>>
User -> NotesListActivity: togglePrivateMode()
activate User
activate NotesListActivity
NotesListActivity -> NotesListAdapter: setPrivateMode(isPrivate:boolean)
activate NotesListAdapter
loop for each note item
NotesListAdapter -> NoteItemData: getSnippet(String)
activate NoteItemData
NoteItemData -> WorkingNote: getContent()
activate WorkingNote
WorkingNote --> NoteItemData: originalContent
deactivate WorkingNote
alt isPrivate == true
NoteItemData -> NoteItemData: generateMaskedContent()
NoteItemData --> NotesListAdapter: coverwith"123456789"
else isPrivate == false
NoteItemData --> NotesListAdapter: originalContent
end
deactivate NoteItemData
end
NotesListAdapter -> NotesListAdapter: notifyDataSetChanged()
NotesListAdapter --> NotesListActivity: displayUpdated
deactivate NotesListAdapter
NotesListActivity --> User: showUpdatedList
deactivate NotesListActivity
deactivate User
@enduml
10search
@startuml
title Minote Text Search Sequence
skinparam sequenceParticipant underline
hide footbox
actor User
participant "NoteEditText" as NoteEditText <<boundary>>
participant "SearchToolbar" as SearchToolbar <<boundary>>
participant "InputMethodManager" as InputMethodManager <<control>>
participant "EditText" as EditText <<boundary>>
participant "Editable" as Editable <<entity>>
participant "Layout" as Layout <<entity>>
User -> NoteEditText: clickSearchButton
activate User
activate NoteEditText
NoteEditText -> SearchToolbar: showSearchToolbar
activate SearchToolbar
SearchToolbar -> SearchToolbar: initializeViews
SearchToolbar -> EditText: requestFocus
activate EditText
SearchToolbar -> InputMethodManager: showSoftInput(searchEditText, SHOW_IMPLICIT)
activate InputMethodManager
InputMethodManager --> EditText: showKeyboard
deactivate InputMethodManager
User -> EditText: inputSearchText(text:String)
EditText -> SearchToolbar: onConfirmClick(text:String)
deactivate EditText
SearchToolbar -> NoteEditText: performSearch(searchText:String)
deactivate SearchToolbar
NoteEditText -> NoteEditText: clearSearchHighlights
NoteEditText -> Editable: getText
activate Editable
Editable --> NoteEditText: content
deactivate Editable
loop for each match
NoteEditText -> NoteEditText: findNextMatch(content:String, searchText:String)
NoteEditText -> Editable: setSpan(BackgroundColorSpan, start:int, end:int, flags:int)
activate Editable
Editable --> NoteEditText: highlightApplied
deactivate Editable
end
NoteEditText -> Layout: getLineForOffset(index:int)
activate Layout
Layout --> NoteEditText: lineNumber
NoteEditText -> Layout: getLineTop(line:int)
Layout --> NoteEditText: yPosition
deactivate Layout
NoteEditText -> NoteEditText: scrollTo(0, yPosition)
NoteEditText --> User: displaySearchResults
User -> SearchToolbar: clickCancelButton
activate SearchToolbar
SearchToolbar -> NoteEditText: clearSearchHighlights
SearchToolbar -> SearchToolbar: hideSearchToolbar
SearchToolbar -> InputMethodManager: hideSoftInputFromWindow
deactivate SearchToolbar
NoteEditText --> User: restoreOriginalText
deactivate NoteEditText
deactivate User
@enduml
11.模板便签
@startuml
title Minote Template Note Sequence
skinparam sequenceParticipant underline
hide footbox
actor User
participant "NotesListActivity" as NotesListActivity <<boundary>>
participant "AlertDialog" as AlertDialog <<boundary>>
participant "NoteEditActivity" as NoteEditActivity <<boundary>>
participant "WorkingNote" as WorkingNote <<entity>>
participant "NotesProvider" as NotesProvider <<control>>
participant "ContentValues" as ContentValues <<entity>>
activate User
User -> NotesListActivity: clickNewNote()
activate NotesListActivity
NotesListActivity -> AlertDialog: showTemplateDialog()
activate AlertDialog
AlertDialog -> AlertDialog: setTitle("选择创建的便签")
AlertDialog -> AlertDialog: setItems(templateItems[])
User -> AlertDialog: selectTemplate(index:int)
AlertDialog --> NotesListActivity: createNewNote(templateType:int)
deactivate AlertDialog
NotesListActivity -> WorkingNote: createNote(context:Context, folderId:long)
activate WorkingNote
WorkingNote -> ContentValues: new ContentValues()
activate ContentValues
ContentValues --> WorkingNote: returnValues
deactivate ContentValues
alt templateType == TEMPLATE_TYPE_1
WorkingNote -> WorkingNote: setNoteValue("模板1预设内容")
else templateType == TEMPLATE_TYPE_2
WorkingNote -> WorkingNote: setNoteValue("模板2预设内容")
else templateType == TEMPLATE_TYPE_3
WorkingNote -> WorkingNote: setNoteValue("模板3预设内容")
end
WorkingNote -> NotesProvider: insert(uri:Uri, values:ContentValues)
activate NotesProvider
NotesProvider --> WorkingNote: noteId:long
deactivate NotesProvider
WorkingNote --> NotesListActivity: newNote
deactivate WorkingNote
NotesListActivity -> NoteEditActivity: startActivity(intent:Intent)
activate NoteEditActivity
NoteEditActivity -> NoteEditActivity: loadNoteData(noteId:long)
NoteEditActivity --> User: displayTemplateNote
deactivate NoteEditActivity
NotesListActivity -> NotesListActivity: showToast(templateName:String)
NotesListActivity --> User: templateCreated
deactivate NotesListActivity
deactivate User
@enduml
分界线以下是弃用的UML顺序图
///////////////////////////////////////////////////////////////////////////////////////////////
架构包图:
@startuml
title Software Architecture Package Diagram
package "Interface Layer" {
package "ui" {
class "UIController" as UI
}
package "widget" {
class "WidgetManager" as Widget
}
package "res" {
class "ResourceLoader" as Res
}
}
package "Business Layer" {
package "etask.remote" {
class "RemoteTask" as Remote
}
package "tool" {
class "ToolUtils" as Tool
}
package "exception" {
class "ExceptionHandler" as Exception
}
}
package "Model Layer" {
class "BusinessModel" as Model
}
package "Data Layer" {
class "DataAccessObject" as Data
}
UI --> Widget : uses
UI --> Res : uses
Widget --> Remote : interacts with
Tool --> Exception : handles
Remote --> Model : processes
Model --> Data : stores
@enduml
Speech版本语音听写
@startuml
title Speech Recognition Process with NoteEditActivity and IATActivity
skinparam sequenceParticipant underline
skinparam stereotypePosition top
hide footbox
actor user
participant "NoteEditActivity" as NEA
participant "IATActivity" as IATA
participant "SpeechRecognizer" as SR
participant "RecognizerListener" as RL
participant "InitListener" as IL
note right of user: 用户启动应用并选择语音识别功能
user -> NEA : 选择语音识别功能
activate NEA
NEA -> IATA : startIATActivity()
activate IATA
note right of IATA: 初始化SDK和SpeechRecognizer
IATA -> SR : createRecognizer(Context, IL)
activate SR
SR --> IATA : onInit(int)
deactivate SR
note right of IATA: 设置识别参数
IATA -> SR : setParameter(String, String)
note right of IATA: 构建语法(如果需要)
IATA -> SR : buildGrammar(String, String, GL)
activate SR
SR --> IATA : onBuildFinish(String, SpeechError)
deactivate SR
note right of IATA: 更新词典(如果需要)
IATA -> SR : updateLexicon(String, String, LXL)
activate SR
SR --> IATA : onLexiconUpdated(String, SpeechError)
deactivate SR
note right of IATA: 开始录音进行识别
IATA -> SR : startListening(RL)
activate SR
SR --> IATA : onBeginOfSpeech()
loop Recording
SR --> IATA : onVolumeChanged(int, byte[])
end
SR --> IATA : onEndOfSpeech()
SR --> IATA : onResult(RecognizerResult, boolean)
SR --> IATA : onError(SpeechError)
deactivate SR
note right of IATA: 处理识别结果
IATA -> user : 展示识别结果
note right of user: 用户完成识别并退出
user -> IATA : 退出识别功能
IATA -> SR : stopListening()
IATA -> SR : destroy()
@enduml
Linux版本
@startuml
title Speech Recognition Process with NoteEditActivity and IATActivity
skinparam sequenceParticipant underline
skinparam stereotypePosition top
hide footbox
actor user
participant "NoteEditActivity" as NoteEdit
participant "IATActivity" as IAT
participant "SpeechRecognizer" as SR
participant "RecognizerListener" as RL
participant "InitListener" as IL
note right of user: 用户启动应用并选择语音识别功能
user -> NoteEdit : 选择语音识别功能
activate NoteEdit
NoteEdit -> IAT : startIATActivity()
activate IAT
note right of IAT: 初始化SDK和SpeechRecognizer
IAT -> SR : createRecognizer(Context, IL)
activate SR
SR --> IAT : onInit(int)
deactivate SR
note right of IAT: 注册监听回调和配置识别参数
IAT -> SR : setParameter(String, String)
note right of IAT: 启动会话
IAT -> SR : startListening(RL)
activate SR
loop Recording
SR --> IAT : onVolumeChanged(int, byte[])
SR --> IAT : onBeginOfSpeech()
IAT -> SR : writeAudio(byte[], int, int)
SR --> IAT : onResult(RecognizerResult, boolean)
SR --> IAT : onEndOfSpeech()
end
note right of IAT: 处理识别结果
IAT -> user : 展示识别结果
note right of user: 用户完成识别并退出
user -> IAT : 退出识别功能
IAT -> SR : stopListening()
IAT -> SR : destroy()
deactivate SR
deactivate IAT
@enduml