A method and device for custom character switching for an AI voice module

By binding role switching commands and conversation data to the AI ​​voice module, and extracting and filtering historical context, the problem of information loss during role switching is solved, and information isolation and dynamic association in multi-role scenarios are realized, improving user experience and the intelligence of system response.

CN121190073BActive Publication Date: 2026-06-16ZHEJIANG LUOPING INFORMATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG LUOPING INFORMATION TECH CO LTD
Filing Date
2025-09-18
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Existing AI voice modules have difficulty accurately distinguishing the historical dialogues associated with different roles when switching roles. This can lead to the loss of the original context information or its overwriting by new content from other roles when the user switches back to the original role, causing confusion in intent tracking.

Method used

By receiving user input of role switching instructions, the system binds the native data of the current session with the role before the switch to form a session data group and records the current dialogue state; it extracts and archives historical context information to generate a context transition data group, and filters it by combining role identity information, permission level and topic tags to extract context content applicable to the target role and update the session state; and it restores the historical context when switching back to the original role.

Benefits of technology

It achieves accurate inheritance and tracking of conversation states among multiple roles, avoids loss of historical information, improves the continuity and intelligence of conversations, and significantly enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121190073B_ABST
    Figure CN121190073B_ABST
Patent Text Reader

Abstract

The application provides a custom role switching method and device for an AI voice module, and relates to the technical field of data processing.The method comprises the following steps: receiving a role switching instruction input by a user, identifying and binding native data of a current session with a first role before switching, and recording a current conversation state of the first role; determining a second role as a switching target according to the role switching instruction input by the user, extracting and archiving historical context information in a first role session data group; screening a context transfer data group in combination with identity information, a permission level and a theme label of the second role, and extracting historical context content applicable to the second role; updating a current conversation state with the second role; and when the user switches back to the first role again, calling the saved first role current conversation state and session data group; and the application improves the autonomy and accuracy of the custom role switching method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method and apparatus for custom role switching in an AI voice module. Background Technology

[0002] In existing technologies, AI voice modules typically use a pre-set character library, allowing users to select specific characters and switch between different voice styles and responses. Users can switch to different characters via voice commands or interface menus, and the system loads the corresponding character's voice parameters and dialogue model to meet diverse interaction needs. This approach has been widely used in smart homes, in-vehicle terminals, and online customer service scenarios, enhancing the system's interactive flexibility.

[0003] In intelligent customer service scenarios, existing technologies typically clear or reset the current conversation context after a user initiates a role switch to prevent information interference between different roles. However, in practical applications, if a user's product questions are first answered by a "pre-sales consultant" and then they switch to a "technical support" role for troubleshooting, the system often struggles to accurately distinguish the historical conversations associated with each role. If the user switches back to their original role to continue asking questions, the original context information may have been lost or overwritten by new content from other roles, leading to confusion in intent tracking. Summary of the Invention

[0004] The purpose of this invention is to provide a method and apparatus for custom role switching in an AI voice module, aiming to solve the problems mentioned in the background art.

[0005] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:

[0006] Firstly, a method for custom role switching in an AI voice module, the method comprising:

[0007] Receive the user's input of a role switching command, bind the original data of the current session with the first role before the switch to form a first role session data group, and record the current dialogue state of the first role;

[0008] Based on the user's input role switching command, the switching target is determined to be the second role. The historical context information in the first role's conversation data group is extracted and archived to generate a context transfer data group for association with the second role. The role switching command includes the switching target and the current dialogue task.

[0009] Based on the dialogue task, and combined with the identity information, permission level and topic tags of the second role, the context transition data group is filtered, and the historical context content applicable to the second role is extracted to form a context invocation dataset exclusive to the second role.

[0010] Based on the context, invoke the dataset and update the current session state with the second role;

[0011] When the user switches back to the first role, the saved current dialogue state and conversation data group of the first role are retrieved to restore the historical context of the first role, so as to achieve accurate inheritance and tracking of the conversation state between multiple roles.

[0012] Preferably, based on the user-inputted role switching command, the target role is determined to be the second role. Historical context information from the first role's session data group is extracted and archived to generate a context transfer data group for association with the second role, including:

[0013] Based on the first role's conversation data group, the dialogue content is segmented according to time sequence and speaking rounds to obtain segmented data, and each data segment is assigned a unique timestamp and speaking sequence number;

[0014] Based on the segmented data, user identity information, permission level and topic tags are extracted and bound to each segment to form a context segment with multidimensional metadata;

[0015] Based on the context fragments, a unique identifier and index are established using the timestamp, speech number, identity information, topic tags, and permission level to generate a context transfer data group for second role association.

[0016] Preferably, based on the dialogue task, and combined with the identity information, permission level, and topic tags of the second role, the context transition data group is filtered to extract historical context content suitable for the second role, forming a context invocation dataset specific to the second role, including:

[0017] Based on the context transition data set, context fragments that match permissions and are related to the topic are filtered out according to the identity information, permission level and topic tags of the second role, forming the first fragment filtering set;

[0018] Based on each context fragment in the first fragment selection set, the comprehensive semantic matching degree with the current dialogue task is calculated through keyword extraction, intent recognition, and semantic relevance. Context fragments that meet the preset comprehensive semantic matching degree threshold are selected to generate the second fragment selection set.

[0019] The context fragments in the second fragment selection set are deduplicated, merged, and conflict-resolved to generate the third fragment selection set.

[0020] For each context fragment in the third fragment filtering set, the sensitive information review process is automatically triggered. Context fragments that require cross-role confirmation or have special permissions are reviewed and decided upon. Context fragments that pass the review are filtered out and a qualified fragment dataset is generated.

[0021] The qualified fragment datasets are sorted according to time sequence to form a context call dataset specific to the second role.

[0022] Preferably, based on the segmented data, user identity information, permission level, and topic tags are extracted and bound to each segment to form a context segment with multidimensional metadata, including:

[0023] Based on the segmented data, the source information of each segment is obtained. User identity information is identified through account identification or voiceprint recognition methods, and it is bound to the data segment as independent metadata to obtain the first segment data.

[0024] Based on the first data segment, the segment content and context are analyzed. Combining the preset role permission model and content sensitivity judgment rules, permission levels are automatically assigned to each segment. The permission levels are then bound to the data segments as independent metadata to generate the second data segment.

[0025] Based on the second data segment, keywords are extracted and themes are summarized from the segment content. The automatically identified theme tags are used as independent metadata and are bound to the data segment along with identity information and permission level to generate a context segment with multi-dimensional metadata.

[0026] Preferably, based on the context transition data set, and based on the identity information, permission level, and topic tags of the second role, context fragments that match permissions and are related to the topic are filtered to form a first fragment filtering set, including:

[0027] Based on the context transition data group, read the permission level of each context fragment and compare it with the permission level of the second role. Filter the context fragments with permission levels equal to or lower than the permission level of the second role to generate the first candidate set.

[0028] Based on the first candidate set, extract the topic tags for each context fragment and compare them with the topic tags of the second character. Only when the topic tag content is completely consistent with the topic tag of the second character or is determined to belong to the same category in the preset tag mapping table, the fragment is retained and the rest of the fragments are removed to form the first fragment filtering set.

[0029] Preferably, based on each context segment in the first segment selection set, its comprehensive semantic matching degree with the current dialogue task is calculated through keyword extraction, intent recognition, and semantic relevance. Context segments that meet a preset comprehensive semantic matching degree threshold are then selected to generate a second segment selection set, including:

[0030] For each context fragment, keywords are extracted and compared with the keyword field of the current dialogue task. Keyword coverage and core word matching are calculated and added together according to preset weights to obtain a keyword relevance score.

[0031] Each context fragment and the text content of the current dialogue task are represented by a semantic feature vector, and a similarity score is calculated using the semantic feature vectors of the two, which is used as the semantic relevance score.

[0032] For each context fragment, the content expression of the fragment is comprehensively analyzed in conjunction with the topic tag, keyword relevance score, and semantic relevance score to determine its relationship with the current dialogue task objective. Figure 1 The consistency is determined, and based on this, the score for matching the segment with the intent of the current dialogue task is determined;

[0033] The keyword relevance score, intent matching score, and semantic relevance score of each context fragment are fused according to preset weights to calculate its comprehensive semantic matching score with the current dialogue task.

[0034] Based on the overall semantic matching degree of all segments, context segments that are equal to or higher than the preset overall semantic matching degree threshold are selected to form a second segment selection set.

[0035] Preferably, the context fragments in the second fragment selection set are deduplicated, merged, and conflict resolved to generate a third fragment selection set, including:

[0036] Based on the second segment selection set, calculate the similarity score between any two context segments. When the similarity score is greater than the preset first similarity threshold, only the context segment with the highest comprehensive semantic matching score is retained, and redundant context segments are removed to form a deduplicated segment set.

[0037] Based on the deduplication fragment set, the content structure and metadata of the context fragments are analyzed. For context fragments under the same topic tag but with different content, when the similarity scores of the two are greater than the preset second similarity threshold, they are merged into a context fragment with a unified expression, generating a merged fragment set.

[0038] Based on the merged fragment set, the fragments are compared sequentially according to time order, permission level, and topic tag. Conflict detection is performed on context fragments with similarity scores greater than the preset third similarity threshold but with differences in metadata.

[0039] When multiple context fragments under the same topic tag are detected to have inconsistent content or permission levels, the context fragment with the higher permission level is retained. If the permission levels are the same, the fragment with the latest time sequence is retained, and the remaining fragments are removed to generate a third fragment filtering set.

[0040] Preferably, for each context fragment in the third fragment filtering set, a sensitive information review process is automatically triggered. Context fragments requiring cross-role confirmation or with special permissions are reviewed and decided upon. Context fragments that pass the review are filtered out, and a qualified fragment dataset is generated, including:

[0041] Based on each context fragment in the third fragment filtering set, the context fragments that need to be reviewed are automatically identified by determining whether their permission level and content attributes meet the preset sensitive information characteristics, cross-role calling rules or special permission transfer conditions.

[0042] For context fragments that need to be reviewed, they are reviewed according to preset automatic review rules, role and permission mapping table and sensitive information identification rules. If the review is successful, they will proceed to the next process. If the review is unsuccessful, the fragments will be automatically isolated and stored or removed from the subsequent context processing.

[0043] For context fragments that cannot be accurately determined by automatic rules, they are pushed to the manual review stage, where they are reviewed by a designated role or system administrator. Once the review is passed, a review pass mark is assigned, and all qualified context fragments are generated into a qualified fragment dataset.

[0044] Preferably, keywords are extracted from each context fragment, compared with the keyword field of the current dialogue task, and the keyword coverage and core word matching degree are calculated. These are then added together according to preset weights to obtain a keyword relevance score, including:

[0045] Extract keywords from the text content of each context segment to obtain the keyword set for that segment;

[0046] The keyword set of this segment is compared one by one with the keyword field of the current dialogue task. The number of keywords contained in the intersection of the two is counted and the ratio is calculated with the total number of keywords in the current dialogue task to obtain the keyword coverage of the segment.

[0047] During the comparison process, the number of intersections between the keyword set of the segment and the core keyword set of the current dialogue task is counted. The number of intersections is divided by the total number of core keywords in the current dialogue task to obtain the core word matching score of the segment.

[0048] Based on a preset weighting ratio, the keyword coverage and core word matching are weighted and summed to obtain the keyword relevance score between the context fragment and the current dialogue task.

[0049] Secondly, a custom role-switching device for an AI voice module, the device comprising:

[0050] The instruction receiving module is used to receive the role switching instruction input by the user, bind the original data of the current session with the first role before the switch to form the first role session data group, and record the current dialogue state of the first role.

[0051] The target determination and archiving module is used to determine the switching target as the second role based on the role switching instruction input by the user, extract and archive the historical context information in the first role's conversation data group, and generate a context transfer data group for association with the second role. The role switching instruction includes the switching target and the current dialogue task.

[0052] The context filtering module is used to filter the context transition data group based on the dialogue task, combined with the identity information, permission level and topic tags of the second role, and extract the historical context content applicable to the second role to form a context call dataset exclusive to the second role.

[0053] The session state update module is used to call the dataset based on the context and update the current session state with the second role;

[0054] The session recovery module is used to restore the historical context of the first role by calling the saved current dialogue state and session data group of the first role when the user switches back to the first role, so as to achieve accurate inheritance and tracking of the session state between multiple roles.

[0055] The above-described solution of the present invention has at least the following beneficial effects:

[0056] By binding user-inputted role-switching commands to the current session's native data, this invention enables the creation of independent session data groups and dialogue state records for each role during role switching, avoiding the loss of historical information caused by directly resetting the context. Compared to existing technologies that only clear or reset the context to achieve role switching, this invention can accurately manage and archive historical contexts for different roles, achieving information isolation and dynamic association in multi-role scenarios. When a user switches roles multiple times within the same session, the system can automatically extract and filter historical content highly relevant to the current target role and dialogue task, generating a dedicated context call dataset. This allows each role to seamlessly inherit its own context during switching, unaffected by dialogue content from other roles, improving session coherence and intelligent tracking capabilities. For example, in intelligent customer service applications, when a user switches from "pre-sales consultant" to "technical support" and then back to the original role, they can continue to ask follow-up questions, accurately recovering and retrieving all historical information related to that role, greatly improving the user experience and system response intelligence in complex multi-role dialogue scenarios. Attached Figure Description

[0057] Figure 1 This is a flowchart of a custom role switching method for an AI voice module provided by an embodiment of the present invention. Detailed Implementation

[0058] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0059] like Figure 1 As shown, an embodiment of the present invention proposes a method for custom role switching in an AI voice module, the method comprising:

[0060] Receive the user's input of a role switching command, bind the original data of the current session with the first role before the switch to form a first role session data group, and record the current dialogue state of the first role;

[0061] Based on the user's input role switching command, the switching target is determined to be the second role. The historical context information in the first role's conversation data group is extracted and archived to generate a context transfer data group for association with the second role. The role switching command includes the switching target and the current dialogue task.

[0062] Based on the dialogue task, and combined with the identity information, permission level and topic tags of the second role, the context transition data group is filtered, and the historical context content applicable to the second role is extracted to form a context invocation dataset exclusive to the second role.

[0063] Based on the context, invoke the dataset and update the current session state with the second role;

[0064] When the user switches back to the first role, the saved current dialogue state and conversation data group of the first role are retrieved to restore the historical context of the first role, so as to achieve accurate inheritance and tracking of the conversation state between multiple roles.

[0065] In this embodiment of the invention, by receiving a user-inputted role-switching command, the native data of the current session is identified and bound to the first role before the switch. This effectively ensures that the session data before and after each role switch is not confused, which is beneficial for the independent management of multi-role session states. When the switch target is determined to be the second role according to the role-switching command, and the historical context information in the first role's session data group is extracted and archived, the historical dialogue information of multiple roles can be separated and archived in the same session, improving the data traceability and tracking capabilities during subsequent role switches. By combining the second role's identity information, permission level, and topic tags to filter the context transfer data group, the most relevant historical context content can be accurately selected for different roles and different dialogue tasks, preventing irrelevant information from being incorrectly inherited, thereby forming a context call dataset exclusive to the second role. By updating the current session state with the second role based on this context call dataset, it can be ensured that the user's context experience is consistent with the real continuous dialogue after switching to the second role, avoiding context breakage due to the switch. For example, in a customer service application scenario, when a user switches from a general consultation role to a complaint handling role, they can seamlessly inherit and call all previous complaint-related context content, greatly improving the flexibility and continuity of the multi-role intelligent dialogue system.

[0066] Specifically, it receives user input of a role switching command, binds the current session's native data with the previous role's identifier to form a first role session data group, and records the first role's current dialogue state, including:

[0067] First, when the AI ​​voice module receives a user's input command to switch roles, it can parse the user's intention to switch through voice recognition, graphical interface clicks, or command input. After obtaining the command, the system first collects all native dialogue data generated in the current session before the switch, as data to be identified. Then, the system assigns identification information related to the first role before the switch to each piece of native data, such as adding role number, role name, or identity identifier fields to the data structure, and uniformly classifies this data into the first role's session data group. Next, the system records the first role's current dialogue state, including the turn of the dialogue, context content, and current intent tracking status. This state information can be stored in a database or cache system and associated with the first role's unique identity. This process ensures that all historical information generated by the original role during the dialogue can be independently archived and traced each time a switch occurs, avoiding data confusion or loss due to the switch operation. For example, in the intelligent customer service scenario, before a user switches from "pre-sales consultant" to "technical support", the system will bind all the questions and answers between the user and the pre-sales consultant, as well as the progress of the last communication, into a dedicated conversation data group and current status for the first role, so that it can be restored at any time later.

[0068] Specifically, based on the context call dataset, the current session state with the second role is updated, including:

[0069] After determining that the target of the role switching is the second role, the system first extracts all historical context fragments closely related to the second role's identity, permission level, and current dialogue task from the aforementioned filtered and generated context call dataset. Then, the system organizes these context fragments according to features such as chronological order, topic tags, and task relevance, constructing a context environment that can be continuously invoked by the second role. Next, the system merges and updates the content of this context call dataset with the current conversation state structure of the second role, including but not limited to: restoring the dialogue node when the second role last left the conversation, reloading historical dialogue fragments related to the task objective, and synchronizing the second role's task progress and unfinished items. The update process uses data overwriting or incremental merging to ensure no omissions or conflicts between the old and new state data. Finally, the system stores the updated second role's conversation state in a dedicated storage area, allowing the second role to naturally continue the previous context logic and obtain a coherent dialogue experience when continuing to interact with the user. For example, in the smart home voice assistant scenario, after a user switches from the "Life Assistant" role to the "Device Manager" role, the system automatically loads all the relevant operations and task contexts of the previous Device Manager role, enabling the new role to accurately continue the previous device management tasks without having to ask questions repeatedly, significantly improving the intelligence and continuity of multi-role voice interaction.

[0070] The AI ​​voice module is a system component for voice interaction built upon artificial intelligence (AI) technologies, particularly natural language processing (NLP), speech recognition and synthesis, and semantic understanding. It typically integrates multiple technologies, such as speech recognition, speech synthesis, dialogue management, and intent recognition, enabling it to interact with users via voice, understand and process user commands or questions, and provide corresponding voice feedback.

[0071] In existing technologies, AI voice modules mainly consist of the following core components:

[0072] Speech Recognition Module: This module is responsible for converting the user's speech into text. Using deep learning algorithms, such as Convolutional Neural Networks (CNNs) or Recurrent Neural Networks (RNNs), it extracts features from the speech signal and matches them with existing language models to achieve efficient and accurate speech-to-text conversion.

[0073] Speech synthesis module: The speech synthesis module interacts with users by converting text into speech. Existing speech synthesis technologies (such as deep neural networks) can generate natural, fluent speech output that simulates human speech expression.

[0074] Natural Language Processing (NLP) Module: This module performs semantic analysis on the text (or text converted from speech) input by the user. Through steps such as word segmentation, entity recognition, syntactic parsing, and semantic understanding, the AI ​​speech module can extract the user's intent and respond appropriately. Common technologies include word embeddings (such as Word2Vec and BERT) and machine learning classifiers (such as support vector machines and decision trees).

[0075] Dialogue Management System: The dialogue management system is responsible for managing multi-turn dialogues based on contextual information and the current dialogue state. It determines the next voice output or task execution based on the current dialogue content, user needs, and historical dialogue records, ensuring the consistency and fluency of the dialogue.

[0076] Role Management and Task Management Modules: In some systems, the AI ​​voice module also integrates role switching functionality, allowing interaction through different roles. For example, in intelligent customer service applications, the system can switch to different roles based on user needs, such as "pre-sales consultant" or "technical support." This module better matches user expectations by switching different role parameters and dialogue models.

[0077] In a preferred embodiment of the present invention, based on the user-inputted role switching command, the switching target is determined to be a second role. Historical context information from the first role's session data group is extracted and archived to generate a context transfer data group for association with the second role, including:

[0078] Based on the first role's conversation data group, the dialogue content is segmented according to time sequence and speaking rounds to obtain segmented data, and each data segment is assigned a unique timestamp and speaking sequence number;

[0079] Based on the segmented data, user identity information, permission level and topic tags are extracted and bound to each segment to form a context segment with multidimensional metadata;

[0080] Based on the context fragments, a unique identifier and index are established using the timestamp, speech number, identity information, topic tags, and permission level to generate a context transfer data group for second role association.

[0081] In this embodiment of the invention, by segmenting the dialogue content of the first role's conversation data group according to time sequence and speaking rounds, and assigning a unique timestamp and speaking sequence number to each data segment, fine-grained management of multi-round dialogue content can be achieved, facilitating subsequent retrieval and tracing. Each segment is further extracted and bound with user identity information, permission level, and topic tags, laying a solid foundation for subsequent context filtering and permission management, ensuring strict separation of conversation data under different permissions and topics. For example, when the same user participates in multi-role interactions in the same conversation with different identities, the system can automatically identify and distinguish the dialogue data generated under different identities. Establishing unique identifiers and indexes through timestamps, speaking sequence numbers, identity information, topic tags, and permission levels not only improves the retrieval efficiency of context segments but also provides effective protection for subsequent cross-role data referencing and security review. Through the above processing, the AI ​​voice module can effectively improve the organization efficiency and security isolation capabilities of conversation data in multi-role concurrent management scenarios. For example, in a customer service system, data between different customer service roles will not be confused, enabling the isolation management of sensitive information according to permissions, ensuring information security and compliant operation.

[0082] In a preferred embodiment of the present invention, based on the dialogue task and combined with the identity information, permission level, and topic tags of the second role, the context transition data group is filtered to extract historical context content suitable for the second role, forming a context invocation dataset specific to the second role, including:

[0083] Based on the context transition data set, context fragments that match permissions and are related to the topic are filtered out according to the identity information, permission level and topic tags of the second role, forming the first fragment filtering set;

[0084] Based on each context fragment in the first fragment selection set, the comprehensive semantic matching degree with the current dialogue task is calculated through keyword extraction, intent recognition, and semantic relevance. Context fragments that meet the preset comprehensive semantic matching degree threshold are selected to generate the second fragment selection set.

[0085] The context fragments in the second fragment selection set are deduplicated, merged, and conflict-resolved to generate the third fragment selection set.

[0086] For each context fragment in the third fragment filtering set, the sensitive information review process is automatically triggered. Context fragments that require cross-role confirmation or have special permissions are reviewed and decided upon. Context fragments that pass the review are filtered out and a qualified fragment dataset is generated.

[0087] The qualified fragment datasets are sorted according to time sequence to form a context call dataset specific to the second role.

[0088] In this embodiment of the invention, by filtering the context transition data group based on the identity information, permission level, and topic tags of the second role, context fragments with matching permissions and topic relevance can be quickly selected for the current dialogue task, greatly improving the accuracy of historical context filtering. Based on keyword extraction, intent recognition, and comprehensive semantic relevance calculation, the system can quantify the semantic matching degree between each context fragment and the current dialogue task, and filter out the most relevant content through thresholds, effectively preventing the misuse of contexts unrelated to the current dialogue task. For example, in a multi-role meeting assistant scenario, when different participants switch to different roles, the system can intelligently extract and push the most relevant meeting content based on the current topic, permissions, and historical identity, supporting decision-making and collaboration. Subsequent deduplication, merging, and conflict resolution of the selected context fragments ensures that the dataset content is unique, consistent, and complete, ultimately forming a sorted, dedicated context call dataset. This allows the second role to obtain historical information most closely related to the current task, achieving seamless context transition across multiple roles.

[0089] In a preferred embodiment of the present invention, based on the fragmented data, user identity information, permission level, and topic tags are extracted and bound to each fragment to form a context fragment with multidimensional metadata, including:

[0090] Based on the segmented data, the source information of each segment is obtained. User identity information is identified through account identification or voiceprint recognition methods, and it is bound to the data segment as independent metadata to obtain the first segment data.

[0091] Based on the first data segment, the segment content and context are analyzed. Combining the preset role permission model and content sensitivity judgment rules, permission levels are automatically assigned to each segment. The permission levels are then bound to the data segments as independent metadata to generate the second data segment.

[0092] Based on the second data segment, keywords are extracted and themes are summarized from the segment content. The automatically identified theme tags are used as independent metadata and are bound to the data segment along with identity information and permission level to generate a context segment with multi-dimensional metadata.

[0093] In this embodiment of the invention, by extracting and binding user identity information, permission levels, and topic tags to each fragment of data, a comprehensive multidimensional metadata description can be established for each context fragment. User identity information is accurately identified through account identification or voiceprint recognition methods, effectively avoiding the risk of identity confusion in multi-user or multi-role scenarios. Binding permission levels to data fragments independently facilitates subsequent information isolation and review under different permission scenarios, ensuring data security and compliance of the system. Automatic extraction and summarization of topic tags gives each conversation content a clear semantic classification, facilitating subsequent task-related contextual retrieval and filtering. For example, in an enterprise knowledge management system, the system can accurately distinguish and archive data related to the same user's operations across different business lines, laying the foundation for subsequent intelligent retrieval and multidimensional analysis, thereby effectively supporting the multi-role, multi-scenario application needs of large-scale AI voice modules.

[0094] Specifically, based on the segmented data, the source information of each segment is obtained, and user identity information is identified through account identification or voiceprint recognition methods, including:

[0095] After the system segments the dialogue content, it first extracts metadata information for each segment, including the conversation initiator, speaking time, and device ID. If the user logs in to the system with an account, the account is directly used as the account identifier field for the segment. If multiple users share a terminal or there are multi-turn voice interactions, voiceprint recognition can be used to compare the extracted voice segment features with pre-stored user voiceprint templates in the database to automatically identify the user. After identity recognition, the system binds the identified user identity information as independent metadata to the segment, ensuring that each segment can be uniquely traced to a specific user. For example, in a smart meeting scenario, the speaking segments of different participants can be distinguished and accurately labeled with the speaker's identity using voiceprint technology, providing a data foundation for subsequent permission determination and content tracking.

[0096] Based on the first segment data, the content and context of the segment are analyzed. Combined with a pre-defined role-based access control model and content sensitivity assessment rules, an automatic access control level is assigned to each segment, specifically including:

[0097] After obtaining the first data segment bound to user identity information, the system performs semantic analysis on the segment content to identify elements such as the business domain, task type, and privacy level involved. Subsequently, the system consults a pre-defined role-based access control model, which typically defines the accessible data scope and sensitivity levels based on user roles (such as ordinary users, administrators, and experts). Combined with content sensitivity judgment rules, if a segment contains sensitive words, proprietary information, or trade secrets, the access requirements for that segment are increased. The system then assigns a corresponding access level to each segment based on the analyzed role category, content type, and sensitivity level, according to the pre-defined access control standards. For example, ordinary Q&A content can be set to open access, while information involving user privacy or high security requirements is assigned higher permissions, authorized only to specific roles, thus achieving tiered security management.

[0098] Based on the data from the second segment, keyword extraction and theme summarization were performed on the segment content, specifically including:

[0099] After acquiring the second segment of data with bound identity information and permission levels, the system uses natural language processing (NLP) technology to segment and extract keywords from the text. Keyword extraction can combine word frequency statistics, TF-IDF algorithms, or entity recognition models to automatically select high-frequency words or domain entities that accurately reflect the main theme of the segment. After extraction, the system aggregates and summarizes multiple highly relevant keywords into topic tags based on their semantic relevance. For example, if a segment contains keywords such as "after-sales service," "fault," and "warranty," it can be summarized into the topic tag "after-sales support." Finally, the system appends the identified keywords and summarized topic tags as metadata to the segment, achieving multi-dimensional semantic classification of the dialogue content, facilitating subsequent topic-based retrieval, filtering, and contextual inheritance.

[0100] In a preferred embodiment of the present invention, based on the context transition data group, and based on the identity information, permission level, and topic tags of the second role, context fragments with matching permissions and related topics are filtered to form a first fragment filtering set, including:

[0101] Based on the context transition data group, read the permission level of each context fragment and compare it with the permission level of the second role. Filter the context fragments with permission levels equal to or lower than the permission level of the second role to generate the first candidate set.

[0102] Based on the first candidate set, extract the topic tags for each context fragment and compare them with the topic tags of the second character. Only when the topic tag content is completely consistent with the topic tag of the second character or is determined to belong to the same category in the preset tag mapping table, the fragment is retained and the rest of the fragments are removed to form the first fragment filtering set.

[0103] In this embodiment of the invention, by reading the permission level of each context fragment in the context transition data group and comparing it with the permission level of the second role, fragment content that meets the permission management requirements can be accurately filtered out, effectively preventing unauthorized roles from accessing sensitive or unauthorized information. Furthermore, by utilizing precise comparison of topic tags and classification processing using a tag mapping table, semantic-level context fragment filtering is achieved, ensuring that the output results are highly relevant to the target role's needs in both topic and permission dimensions. This filtering method significantly improves the system's accuracy in context adaptation in complex multi-role dialogue scenarios. For example, in a smart assistant application, when switching between a regular user and an administrator user, only the administrator can access historical fragments related to the management topic, while regular users can only obtain conversation content consistent with their permissions and the current topic, thus achieving efficient and secure multi-role context management.

[0104] The preset label mapping table specifically includes:

[0105] The system pre-establishes a topic tag mapping table, which contains all available topic tags, their corresponding relationships, and category affiliations. This tag mapping table not only records the standard names of tags but also includes synonyms, similar words, and their parent categories. For example, the tag "after-sales support" can be mapped to the "customer service" category, and the tags "consultation" and "inquiry" are classified in the same category or considered synonyms. During the actual filtering process, the system first reads the topic tags of each context fragment and then compares them against the corresponding relationships in the tag mapping table. When the topic tags of a context fragment are completely identical to those of the second role, or are defined as belonging to the same category in the tag mapping table, the system determines it as a relevant tag and retains the fragment for subsequent processing. This mapping table can be established through a combination of manual compilation and automatic statistics and supports dynamic expansion to adapt to changes in topic tags under new business scenarios.

[0106] In a preferred embodiment of the present invention, based on each context segment in the first segment selection set, its comprehensive semantic matching degree with the current dialogue task is calculated through keyword extraction, intent recognition, and semantic relevance. Context segments that meet a preset comprehensive semantic matching degree threshold are then selected to generate a second segment selection set, including:

[0107] For each context fragment, keywords are extracted and compared with the keyword field of the current dialogue task. Keyword coverage and core word matching are calculated and added together according to preset weights to obtain a keyword relevance score.

[0108] Each context fragment and the text content of the current dialogue task are represented by a semantic feature vector, and a similarity score is calculated using the semantic feature vectors of the two, which is used as the semantic relevance score.

[0109] For each context fragment, the content expression of the fragment is comprehensively analyzed in conjunction with the topic tag, keyword relevance score, and semantic relevance score to determine its relationship with the current dialogue task objective. Figure 1 The consistency is determined, and based on this, the score for matching the segment with the intent of the current dialogue task is determined;

[0110] The keyword relevance score, intent matching score, and semantic relevance score of each context fragment are fused according to preset weights to calculate its comprehensive semantic matching score with the current dialogue task.

[0111] Based on the overall semantic matching degree of all segments, context segments that are equal to or higher than the preset overall semantic matching degree threshold are selected to form a second segment selection set.

[0112] In this embodiment of the invention, comprehensive semantic matching degree calculation under multi-dimensional features is achieved by extracting keywords, recognizing intent, and analyzing semantic relevance for each context segment. This method integrates information such as keyword coverage, core word matching degree, intent matching, and semantic similarity to the current dialogue task of the context segment, and uses a weighted scoring method to comprehensively evaluate the correlation strength between the segment content and the dialogue task. By setting a comprehensive semantic matching degree threshold, the system can automatically filter out historical context content most closely related to the current dialogue task, significantly improving the accuracy of the AI ​​voice module in inheriting contextual information and understanding context. For example, in a project collaboration system, when a user switches to the role of technical lead, the system can accurately select historical segments involving technical solutions, project difficulties, etc., that are highly consistent with the current task, providing data support for efficient decision-making and intelligent suggestions.

[0113] Specifically, a semantic feature vector is generated for each context segment and the text content of the current dialogue task. A similarity score is calculated using the semantic feature vectors of the two segments, which serves as the semantic relevance score. This includes:

[0114] The system extracts semantic features from the text content of each context segment and the text content of the current dialogue task. This processing is typically based on existing natural language understanding models (such as word vectors, sentence vectors, or pre-trained language models based on deep learning), transforming each text segment into a set of feature vectors with fixed dimensions and semantic distribution. The system then calculates the similarity between the two feature vectors, using methods such as the angle between vectors, distance, or relevance measures. In this invention, to avoid mathematical formulas, the system compares the values ​​of each dimension of the two vectors, calculates their similarity, and outputs a score between 0 and 1 according to predefined similarity rules; a higher score indicates stronger semantic relevance. Finally, this score serves as the semantic relevance score between the context segment and the current dialogue task, providing input for subsequent comprehensive matching calculations and filtering.

[0115] Specifically, for each context segment, the content expression of the segment is comprehensively analyzed in relation to the current dialogue task objective, combining topic tags, keyword relevance scores, and semantic relevance scores. Figure 1 The consistency score is used to determine the match between the segment and the intent of the current dialogue task, specifically including:

[0116] For each context fragment, the system first determines whether the fragment's topic tag is consistent with or belongs to the same category as the topic tag of the current dialogue task. If they are consistent, a higher topic tag relevance weight is assigned. Subsequently, the system combines the calculated keyword relevance score (i.e., the weighted score of the fragment's keyword coverage and core word matching with the dialogue task's keywords) and the semantic relevance score (i.e., the overall semantic similarity score between the fragment text and the dialogue task text) to perform a weighted fusion of these multiple scores. The specific process of weighted fusion is as follows: the topic tag relevance weight, keyword relevance score, and semantic relevance score are added together according to preset weights to obtain a comprehensive score. The system uses this comprehensive score as the indicator of the fragment's content's relevance to the current dialogue task's objective. Figure 1 The system measures the consistency of the intent matching score and uses this score as the intent matching score for that segment. A higher intent matching score indicates greater applicability and reference value of the segment for the current dialogue task. The system can set a threshold based on the intent matching score, retaining only context segments with scores reaching or exceeding that threshold for subsequent calls.

[0117] In a preferred embodiment of the present invention, the context fragments in the second fragment filtering set are deduplicated, merged, and conflict resolved to generate a third fragment filtering set, including:

[0118] Based on the second segment selection set, calculate the similarity score between any two context segments. When the similarity score is greater than the preset first similarity threshold, only the context segment with the highest comprehensive semantic matching score is retained, and redundant context segments are removed to form a deduplicated segment set.

[0119] Based on the deduplication fragment set, the content structure and metadata of the context fragments are analyzed. For context fragments under the same topic tag but with different content, when the similarity scores of the two are greater than the preset second similarity threshold, they are merged into a context fragment with a unified expression, generating a merged fragment set.

[0120] Based on the merged fragment set, the fragments are compared sequentially according to time order, permission level, and topic tag. Conflict detection is performed on context fragments with similarity scores greater than the preset third similarity threshold but with differences in metadata.

[0121] When multiple context fragments under the same topic tag are detected to have inconsistent content or permission levels, the context fragment with the higher permission level is retained. If the permission levels are the same, the fragment with the latest time sequence is retained, and the remaining fragments are removed to generate a third fragment filtering set.

[0122] In this embodiment of the invention, by performing deduplication, merging, and conflict resolution on context fragments in the second fragment filtering set, the uniqueness and consistency of historical context data can be significantly improved. By calculating the similarity scores between context fragments, only the fragments with the highest semantic matching degree are retained, effectively removing duplicate or redundant information. When semantically merging fragments with different content under the same topic tag, different expressions of the same fact or event can be uniformly summarized, avoiding information fragmentation and improving the integrity of the context. Through conflict detection rules, fragments with higher permission levels or the latest time sequence are automatically identified and retained, ensuring that the final generated dataset has both accuracy and authority. For example, in the scenario of an intelligent legal assistant, when multiple lawyers submit similar opinions on the same case, the system can automatically merge, deduplicate, and filter authoritative opinions, helping users quickly obtain consistent and complete historical references.

[0123] Specifically, based on the second segment selection set, the similarity score between any two context segments is calculated, including:

[0124] After obtaining the second set of selected segments, the system compares the content of each pair of context segments within the set. During the comparison, the text content of each segment is first preprocessed, including stop word removal, format standardization, and punctuation unification, to facilitate subsequent analysis. Then, natural language processing methods (such as pre-trained language models or word segmentation techniques) are used to convert each segment into a corresponding semantic feature vector. For any pair of segments, the system compares their respective semantic feature vectors and calculates the similarity between the two segments in the semantic dimension. The comparison method can follow this flow: all semantic features of the two segments are matched item by item, and the number of identical or similar features is compared to the total number of features to obtain a similarity score between 0 and 1. The higher the score, the stronger the similarity between the two segments in terms of content expression and semantic intent. The system saves the similarity scores of all paired segments to provide a basis for subsequent deduplication and merging.

[0125] Specifically, based on the deduplicated fragment set, the content structure and metadata of the context fragments are analyzed. For context fragments under the same topic tag but with different content, when their similarity scores are greater than a preset second similarity threshold, they are merged into a single context fragment with a unified expression, generating a merged fragment set, which specifically includes:

[0126] After deduplication, the system groups the remaining context fragments by topic tags, ensuring that each group contains only fragments with the same topic tags. For multiple fragments with differing content within each group, the system retrieves the previously calculated similarity scores. When the similarity score between two or more fragments exceeds the system's preset second similarity threshold, they are considered to express different descriptions of the same fact or event. At this point, the system performs content structure analysis on these fragments, summarizing and merging representative information points from different fragments, removing duplicate or conflicting information. For example, if one fragment describes "device cannot start" and another describes "device black screen upon startup," and both belong to the topic of "device malfunction" and have high similarity, the system can summarize them as "the device has a problem of not starting or having a black screen upon startup." The merged fragments retain all valuable details while maintaining a unified expression. Finally, all merged fragments and unmerged fragments together form a new merged fragment set, preparing for subsequent conflict detection and context invocation.

[0127] In a preferred embodiment of the present invention, for each context fragment in the third fragment filtering set, a sensitive information review process is automatically triggered. Context fragments requiring cross-role confirmation or special permissions are reviewed and decided upon. Context fragments that pass the review are filtered out, and a qualified fragment dataset is generated, including:

[0128] Based on each context fragment in the third fragment filtering set, the context fragments that need to be reviewed are automatically identified by determining whether their permission level and content attributes meet the preset sensitive information characteristics, cross-role calling rules or special permission transfer conditions.

[0129] For context fragments that need to be reviewed, they are reviewed according to preset automatic review rules, role and permission mapping table and sensitive information identification rules. If the review is successful, they will proceed to the next process. If the review is unsuccessful, the fragments will be automatically isolated and stored or removed from the subsequent context processing.

[0130] For context fragments that cannot be accurately determined by automatic rules, they are pushed to the manual review stage, where they are reviewed by a designated role or system administrator. Once the review is passed, a review pass mark is assigned, and all qualified context fragments are generated into a qualified fragment dataset.

[0131] In this embodiment of the invention, by automatically reviewing the sensitive information of each context fragment in the third fragment screening set, sensitive content or information with special permissions can be comprehensively screened and isolated, ensuring the security and compliance of historical data. The automatic review rules can efficiently identify fragments requiring key control based on permission levels, content attributes, and sensitive information characteristics, greatly reducing the burden of manual review. For fragments that cannot be accurately judged by automatic rules, a manual assisted review process is introduced to make the review results more accurate and controllable. All qualified fragments are uniformly included in the qualified fragment dataset, providing a compliant and secure data foundation for subsequent context calls. For example, in a medical and health consultation scenario, historical content involving patient privacy or sensitive data can be automatically screened and isolated, accessible only to authorized medical roles, improving system compliance and user data security.

[0132] Among them, the preset sensitive information characteristics, cross-role call rules, or special permission transfer conditions specifically include:

[0133] Based on actual business needs, the system pre-defines a sensitive information feature database, cross-role access rules, and special permission transfer conditions. The sensitive information feature database includes a set of keywords, phrases, regular expressions, and contextual patterns used to identify sensitive content, such as personal privacy, financial data, and patented technologies. This database can be pre-defined through keyword lists, category labels, or rule scripts. Cross-role access rules clearly define which roles have the right to access, modify, or forward certain types of information; for example, only administrators and security auditors can access classified data across departments. Special permission transfer conditions are used to constrain the flow of sensitive information, such as allowing access to specific context fragments only after a lower-level role has obtained authorization from a higher-level role. When reviewing context fragments, the system first matches the content to whether it matches the sensitive information features. If a match is found, it further checks whether it meets the cross-role access or permission transfer conditions. Only when all conditions are met does the system allow the relevant role to access or call the context fragment; otherwise, it isolates the fragment or issues a permission prompt, ensuring that the entire information flow is controllable and compliant.

[0134] The preset automatic review rules, role-permission mapping table, and sensitive information identification rules specifically include:

[0135] The system establishes an automated review rule base by combining human experience with automatic learning to conduct sensitivity and permission compliance reviews on context fragments. Automated review rules typically include multi-dimensional standards at the content, behavior, and process levels. Content-level rules automatically detect whether text contains restricted words, confidentiality markers, or strings with specific formats based on a sensitive information feature library. Behavioral-level rules detect the scenarios in which users request cross-role access, and process-level rules determine whether permission transfer or superior approval has been completed. A role-permission mapping table records the data access, editing, and transfer permission scopes for various roles in a matrix or hierarchical structure, facilitating the system's automatic determination of the legitimacy of access requests. Sensitive information identification rules combine semantic understanding algorithms, entity recognition tools, and custom templates to check text content item by item. If sensitive entities are found or information is marked as controlled, the system automatically triggers isolation, prompts, or approval processes. For example, when a context fragment involves sensitive fields such as "ID number" or "bank card number," the system automatically marks the fragment as highly sensitive content through matching and rule judgment, allowing access only after approval. All of the above rules are flexibly adjustable and support continuous expansion according to business development.

[0136] In a preferred embodiment of the present invention, keywords are extracted from each context segment, compared with the keyword field of the current dialogue task, and the keyword coverage and core word matching degree are calculated. These are then added together according to preset weights to obtain a keyword relevance score, including:

[0137] Extract keywords from the text content of each context segment to obtain the keyword set for that segment;

[0138] The keyword set of this segment is compared one by one with the keyword field of the current dialogue task. The number of keywords contained in the intersection of the two is counted and the ratio is calculated with the total number of keywords in the current dialogue task to obtain the keyword coverage of the segment.

[0139] During the comparison process, the number of intersections between the keyword set of the segment and the core keyword set of the current dialogue task is counted. The number of intersections is divided by the total number of core keywords in the current dialogue task to obtain the core word matching score of the segment.

[0140] Based on a preset weighting ratio, the keyword coverage and core word matching are weighted and summed to obtain the keyword relevance score between the context fragment and the current dialogue task.

[0141] In this embodiment of the invention, by extracting keywords from the text content of each context segment and systematically comparing them with the keyword fields of the current dialogue task, keyword coverage and core word matching can be quantitatively calculated, achieving accurate quantification of the relevance of the context segment to the current task. By using preset weights to weight and fuse the two indicators, the system effectively improves its ability to discriminate keyword relevance scores, enabling it to intelligently filter out the content most suitable for the current context from a large number of historical segments. For example, in an intelligent customer support scenario, when a user describes a complex problem, the system can automatically retrieve the most relevant past interactions based on the high matching and coverage of core keywords, improving the accuracy and personalization of responses, enhancing user experience and problem-solving efficiency.

[0142] Specifically, keywords are extracted from the text content of each context segment to obtain the keyword set for that segment, which includes:

[0143] In this embodiment, keyword extraction is achieved through Natural Language Processing (NLP) techniques, specifically using word frequency analysis, TF-IDF (Term Frequency-Inverse Document Frequency), and word embedding techniques. First, the system extracts all available words from the text content of the context segment. Then, a word frequency statistics algorithm is applied to calculate the frequency of each word in the text, thereby measuring the word's importance. Next, the TF-IDF algorithm is used for further optimization, calculating the relative importance of each word in the context segment compared to the entire corpus. TF-IDF, by combining the ratio of term frequency to inverse document frequency, can effectively identify representative keywords in a specific context.

[0144] To improve the accuracy of keyword extraction, the system also incorporates word embedding techniques (such as Word2Vec or BERT) to transform each word into a high-dimensional vector and identify potential core keywords by calculating the similarity between words and their contextual semantics. All keywords extracted from the context fragment are compiled into a keyword set, which represents the core content of the fragment and aids in subsequent semantic analysis and matching. This process not only improves the accuracy of keyword extraction but also ensures precise parsing of long text content.

[0145] The methods for extracting keywords and core keywords for the current session task specifically include:

[0146] First, based on the specific content of the dialogue task and in conjunction with the task description or preset template, the system identifies the main domains and semantic objects related to the task. These semantic objects can be nouns, verbs, operation instructions, etc., specific to a particular domain. Then, based on the topic tags or domain vocabulary defined in the task, the system uses semantic analysis tools to parse the text, extract words directly related to the task, and form a preliminary keyword set for the task.

[0147] Based on the task keyword set, the system uses deep semantic matching technology to identify core keywords. Core keywords refer to those elements that are most critical to the task objective or user needs. For example, for the "product search" task, core keywords might include "product," "search," and other product-related keywords such as "price" and "model." Through contextual analysis, the system can dynamically filter out the most representative words, ensuring the accuracy and precision of the task keywords.

[0148] To further improve the identification of core keywords, the system also utilizes contextual analysis to match the task's context with the keyword set. By leveraging contextual information from the dialogue history, the system can better understand the user's intent, thereby improving the accuracy of task keyword extraction. Furthermore, the system can assign different weight values ​​to keywords based on the task's priority, helping it better identify key task content in subsequent semantic matching. Ultimately, these keywords will be used for subsequent intent recognition and task matching, ensuring the dialogue system can accurately respond to the user's needs.

[0149] Embodiments of the present invention also provide a custom role switching device for an AI voice module, the device comprising:

[0150] The instruction receiving module is used to receive the role switching instruction input by the user, bind the original data of the current session with the first role before the switch to form the first role session data group, and record the current dialogue state of the first role.

[0151] The target determination and archiving module is used to determine the switching target as the second role based on the role switching instruction input by the user, extract and archive the historical context information in the first role's conversation data group, and generate a context transfer data group for association with the second role. The role switching instruction includes the switching target and the current dialogue task.

[0152] The context filtering module is used to filter the context transition data group based on the dialogue task, combined with the identity information, permission level and topic tags of the second role, and extract the historical context content applicable to the second role to form a context call dataset exclusive to the second role.

[0153] The session state update module is used to call the dataset based on the context and update the current session state with the second role;

[0154] The session recovery module is used to restore the historical context of the first role by calling the saved current dialogue state and session data group of the first role when the user switches back to the first role, so as to achieve accurate inheritance and tracking of the session state between multiple roles.

[0155] It should be noted that this device is a device corresponding to the above method. All implementation methods in the above method embodiments are applicable to this embodiment and can achieve the same technical effect.

[0156] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for custom role switching in an AI voice module, characterized in that, The method includes: Receive the user's input of a role switching command, bind the original data of the current session with the first role before the switch to form a first role session data group, and record the current dialogue state of the first role; Based on the user's input role switching command, the switching target is determined to be the second role. The historical context information in the first role's conversation data group is extracted and archived to generate a context transfer data group for association with the second role. The role switching command includes the switching target and the current dialogue task. Based on the dialogue task, and combined with the identity information, permission level and topic tags of the second role, the context transition data group is filtered, and the historical context content applicable to the second role is extracted to form a context invocation dataset exclusive to the second role. Based on the context, invoke the dataset and update the current session state with the second role; When the user switches back to the first role, the saved current dialogue state and conversation data group of the first role are called to restore the historical context of the first role, so as to achieve accurate inheritance and tracking of the conversation state between multiple roles. Based on the user's input of a role switching command, the target role is determined to be the second role. Historical context information from the first role's session data group is extracted and archived to generate a context transfer data group for association with the second role, including: Based on the first role's conversation data group, the dialogue content is segmented according to time sequence and speaking rounds to obtain segmented data, and each data segment is assigned a unique timestamp and speaking sequence number; Based on the segmented data, user identity information, permission level and topic tags are extracted and bound to each segment to form a context segment with multidimensional metadata; Based on the context fragments, a unique identifier and index are established through their timestamps, speech numbers, identity information, topic tags, and permission levels to generate a context transfer data group for second role association; Based on the dialogue task, and combined with the second role's identity information, permission level, and topic tags, the context transition data group is filtered to extract historical context content suitable for the second role, forming a context invocation dataset specific to the second role, including: Based on the context transition data set, context fragments that match permissions and are related to the topic are filtered out according to the identity information, permission level and topic tags of the second role, forming the first fragment filtering set; Based on each context fragment in the first fragment selection set, the comprehensive semantic matching degree with the current dialogue task is calculated through keyword extraction, intent recognition, and semantic relevance. Context fragments that meet the preset comprehensive semantic matching degree threshold are selected to generate the second fragment selection set. The context fragments in the second fragment selection set are deduplicated, merged, and conflict-resolved to generate the third fragment selection set. For each context fragment in the third fragment filtering set, the sensitive information review process is automatically triggered. Context fragments that require cross-role confirmation or have special permissions are reviewed and decided upon. Context fragments that pass the review are filtered out and a qualified fragment dataset is generated. The qualified fragment datasets are sorted according to time sequence to form a context call dataset specific to the second role.

2. The method for custom role switching in an AI voice module according to claim 1, characterized in that, Based on the segmented data, user identity information, permission level, and topic tags are extracted and bound to each segment to form a context segment with multidimensional metadata, including: Based on the segmented data, the source information of each segment is obtained. User identity information is identified through account identification or voiceprint recognition methods, and it is bound to the data segment as independent metadata to obtain the first segment data. Based on the first data segment, the segment content and context are analyzed. Combining the preset role permission model and content sensitivity judgment rules, permission levels are automatically assigned to each segment. The permission levels are then bound to the data segments as independent metadata to generate the second data segment. Based on the second data segment, keywords are extracted and themes are summarized from the segment content. The automatically identified theme tags are used as independent metadata and are bound to the data segment along with identity information and permission level to generate a context segment with multi-dimensional metadata.

3. The method for custom role switching in an AI voice module according to claim 1, characterized in that, Based on the context transition data set, and using the second role's identity information, permission level, and topic tags, context fragments that match permissions and are related to the topic are filtered to form the first fragment filtering set, including: Based on the context transition data group, read the permission level of each context fragment and compare it with the permission level of the second role. Filter the context fragments with permission levels equal to or lower than the permission level of the second role to generate the first candidate set. Based on the first candidate set, extract the topic tags for each context fragment and compare them with the topic tags of the second character. Only when the topic tag content is completely consistent with the topic tag of the second character or is determined to belong to the same category in the preset tag mapping table, the fragment is retained and the rest of the fragments are removed to form the first fragment filtering set.

4. The method for custom role switching in an AI voice module according to claim 1, characterized in that, For each context segment in the first segment selection set, its comprehensive semantic matching degree with the current dialogue task is calculated through keyword extraction, intent recognition, and semantic relevance. Context segments that meet the preset comprehensive semantic matching degree threshold are selected to generate the second segment selection set, including: For each context fragment, keywords are extracted and compared with the keyword field of the current dialogue task. Keyword coverage and core word matching are calculated and added together according to preset weights to obtain a keyword relevance score. Each context fragment and the text content of the current dialogue task are represented by a semantic feature vector, and a similarity score is calculated using the semantic feature vectors of the two, which is used as the semantic relevance score. For each context fragment, the content expression of the fragment is analyzed in conjunction with the topic tag, keyword relevance score and semantic relevance score to comprehensively analyze the consistency between the fragment's content expression and the intent of the current dialogue task objective, and the intent matching score of the fragment with the current dialogue task is determined accordingly. The keyword relevance score, intent matching score, and semantic relevance score of each context fragment are fused according to preset weights to calculate its comprehensive semantic matching score with the current dialogue task. Based on the overall semantic matching degree of all segments, context segments that are equal to or higher than the preset overall semantic matching degree threshold are selected to form a second segment selection set.

5. A method for custom role switching in an AI voice module according to claim 1, characterized in that, The context fragments in the second fragment selection set are deduplicated, merged, and conflict resolved to generate the third fragment selection set, which includes: Based on the second segment selection set, calculate the similarity score between any two context segments. When the similarity score is greater than the preset first similarity threshold, only the context segment with the highest comprehensive semantic matching score is retained, and redundant context segments are removed to form a deduplicated segment set. Based on the deduplication fragment set, the content structure and metadata of the context fragments are analyzed. For context fragments under the same topic tag but with different content, when the similarity scores of the two are greater than the preset second similarity threshold, they are merged into a context fragment with a unified expression, generating a merged fragment set. Based on the merged fragment set, the fragments are compared sequentially according to time order, permission level, and topic tag. Conflict detection is performed on context fragments with similarity scores greater than the preset third similarity threshold but with differences in metadata. When multiple context fragments under the same topic tag are detected to have inconsistent content or permission levels, the context fragment with the higher permission level is retained. If the permission levels are the same, the fragment with the latest time sequence is retained, and the remaining fragments are removed to generate a third fragment filtering set.

6. The method for custom role switching in an AI voice module according to claim 1, characterized in that, For each context fragment in the third fragment filtering set, a sensitive information review process is automatically triggered. Context fragments requiring cross-role confirmation or special permissions are reviewed and decided upon. Context fragments that pass the review are filtered out, generating a qualified fragment dataset, including: Based on each context fragment in the third fragment filtering set, the context fragments that need to be reviewed are automatically identified by determining whether their permission level and content attributes meet the preset sensitive information characteristics, cross-role calling rules or special permission transfer conditions. For context fragments that need to be reviewed, they are reviewed according to preset automatic review rules, role and permission mapping table and sensitive information identification rules. If the review is successful, they will proceed to the next process. If the review is unsuccessful, the fragments will be automatically isolated and stored or removed from the subsequent context processing. For context fragments that cannot be accurately determined by automatic rules, they are pushed to the manual review stage, where they are reviewed by a designated role or system administrator. Once the review is passed, a review pass mark is assigned, and all qualified context fragments are generated into a qualified fragment dataset.

7. A method for customizing role switching in an AI voice module according to claim 4, characterized in that, For each context fragment, keywords are extracted and compared with the keyword field of the current dialogue task. Keyword coverage and core word matching are calculated and summed according to preset weights to obtain a keyword relevance score, including: Extract keywords from the text content of each context segment to obtain the keyword set for that segment; The keyword set of this segment is compared one by one with the keyword field of the current dialogue task. The number of keywords contained in the intersection of the two is counted and the ratio is calculated with the total number of keywords in the current dialogue task to obtain the keyword coverage of the segment. During the comparison process, the number of intersections between the keyword set of the segment and the core keyword set of the current dialogue task is counted. The number of intersections is divided by the total number of core keywords in the current dialogue task to obtain the core word matching score of the segment. Based on a preset weighting ratio, the keyword coverage and core word matching are weighted and summed to obtain the keyword relevance score between the context fragment and the current dialogue task.

8. A customizable role switching device for an AI voice module, characterized in that, The apparatus, used in the method as described in any one of claims 1 to 7, comprises: The instruction receiving module is used to receive the role switching instruction input by the user, bind the original data of the current session with the first role before the switch to form the first role session data group, and record the current dialogue state of the first role. The target determination and archiving module is used to determine the switching target as the second role based on the role switching instruction input by the user, extract and archive the historical context information in the first role's conversation data group, and generate a context transfer data group for association with the second role. The role switching instruction includes the switching target and the current dialogue task. The context filtering module is used to filter the context transition data group based on the dialogue task, combined with the identity information, permission level and topic tags of the second role, and extract the historical context content applicable to the second role to form a context call dataset exclusive to the second role. The session state update module is used to call the dataset based on the context and update the current session state with the second role; The session recovery module is used to restore the historical context of the first role by calling the saved current dialogue state and session data group of the first role when the user switches back to the first role, so as to achieve accurate inheritance and tracking of the session state between multiple roles.